Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\CssSelector\Tests\Parser;
use PHPUnit\Framework\TestCase;
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\TokenStream;
class TokenStreamTest extends 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()
{
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$this->expectException(SyntaxErrorException::class);
$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()
{
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$this->expectException(SyntaxErrorException::class);
$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());
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\CssSelector\Tests\Parser;
use PHPUnit\Framework\TestCase;
use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
use Symfony\Component\CssSelector\Parser\Token;
use Symfony\Component\CssSelector\Parser\TokenStream;
class TokenStreamTest extends 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()
{
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$this->expectException(SyntaxErrorException::class);
$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()
{
$stream = new TokenStream();
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
$this->expectException(SyntaxErrorException::class);
$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());
}
}
Function Calls
None |
Stats
MD5 | 91b9ece3518c14b540f4d232cfdf5fbc |
Eval Count | 0 |
Decode Time | 98 ms |