class TokenStreamTest in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/css-selector/Tests/Parser/TokenStreamTest.php \Symfony\Component\CssSelector\Tests\Parser\TokenStreamTest
Hierarchy
- class \Symfony\Component\CssSelector\Tests\Parser\TokenStreamTest extends \Symfony\Component\CssSelector\Tests\Parser\PHPUnit_Framework_TestCase
Expanded class hierarchy of TokenStreamTest
File
- vendor/
symfony/ css-selector/ Tests/ Parser/ TokenStreamTest.php, line 17
Namespace
Symfony\Component\CssSelector\Tests\ParserView source
class TokenStreamTest extends \PHPUnit_Framework_TestCase {
public function testGetNext() {
$stream = new TokenStream();
$stream
->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0));
$stream
->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2));
$stream
->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3));
$this
->assertSame($t1, $stream
->getNext());
$this
->assertSame($t2, $stream
->getNext());
$this
->assertSame($t3, $stream
->getNext());
}
public function testGetPeek() {
$stream = new TokenStream();
$stream
->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0));
$stream
->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2));
$stream
->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3));
$this
->assertSame($t1, $stream
->getPeek());
$this
->assertSame($t1, $stream
->getNext());
$this
->assertSame($t2, $stream
->getPeek());
$this
->assertSame($t2, $stream
->getPeek());
$this
->assertSame($t2, $stream
->getNext());
}
public function testGetNextIdentifier() {
$stream = new TokenStream();
$stream
->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0));
$this
->assertEquals('h1', $stream
->getNextIdentifier());
}
public function testFailToGetNextIdentifier() {
$this
->setExpectedException('Symfony\\Component\\CssSelector\\Exception\\SyntaxErrorException');
$stream = new TokenStream();
$stream
->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$stream
->getNextIdentifier();
}
public function testGetNextIdentifierOrStar() {
$stream = new TokenStream();
$stream
->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0));
$this
->assertEquals('h1', $stream
->getNextIdentifierOrStar());
$stream
->push(new Token(Token::TYPE_DELIMITER, '*', 0));
$this
->assertNull($stream
->getNextIdentifierOrStar());
}
public function testFailToGetNextIdentifierOrStar() {
$this
->setExpectedException('Symfony\\Component\\CssSelector\\Exception\\SyntaxErrorException');
$stream = new TokenStream();
$stream
->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$stream
->getNextIdentifierOrStar();
}
public function testSkipWhitespace() {
$stream = new TokenStream();
$stream
->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0));
$stream
->push($t2 = new Token(Token::TYPE_WHITESPACE, ' ', 2));
$stream
->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'h1', 3));
$stream
->skipWhitespace();
$this
->assertSame($t1, $stream
->getNext());
$stream
->skipWhitespace();
$this
->assertSame($t3, $stream
->getNext());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function | ||
TokenStreamTest:: |
public | function |