* * 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\Handler; use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Parser\Reader; use Symfony\Component\CssSelector\Parser\Token; use Symfony\Component\CssSelector\Parser\TokenStream; /** * @author Jean-François Simon */ abstract class AbstractHandlerTest extends TestCase { /** @dataProvider getHandleValueTestData */ public function testHandleValue($value, Token $expectedToken, $remainingContent) { $reader = new Reader($value); $stream = new TokenStream(); $this->assertTrue($this->generateHandler()->handle($reader, $stream)); $this->assertEquals($expectedToken, $stream->getNext()); $this->assertRemainingContent($reader, $remainingContent); } /** @dataProvider getDontHandleValueTestData */ public function testDontHandleValue($value) { $reader = new Reader($value); $stream = new TokenStream(); $this->assertFalse($this->generateHandler()->handle($reader, $stream)); $this->assertStreamEmpty($stream); $this->assertRemainingContent($reader, $value); } abstract public function getHandleValueTestData(); abstract public function getDontHandleValueTestData(); abstract protected function generateHandler(); protected function assertStreamEmpty(TokenStream $stream) { $property = new \ReflectionProperty($stream, 'tokens'); $property->setAccessible(true); $this->assertEquals(array(), $property->getValue($stream)); } protected function assertRemainingContent(Reader $reader, $remainingContent) { if ('' === $remainingContent) { $this->assertEquals(0, $reader->getRemainingLength()); $this->assertTrue($reader->isEOF()); } else { $this->assertEquals(strlen($remainingContent), $reader->getRemainingLength()); $this->assertEquals(0, $reader->getOffset($remainingContent)); } } } __halt_compiler();----SIGNATURE:----RSWnm5NxwjPzbqMKbaZGY+Li2kj4eZnk2vl7Pzincvv4k85JDLH9Vw4YYdGWFdebJ485Q/QCKG/7Ti+KIZtcSUkgFESoTAbqN9GFapJK/byns82RUWnwPV0cvZrIlv+c/Vzaru5APBiK9FdbzV1dT1vvWDI4P4gSqE5VJTNCs291NIe3V4ch8f0h7xqY7B+1gT4QEONHyKVA4tja+x3UuC7K5df8RXxiqaVSFsiwwafud6OEV4RLCMK3i5XE+7CDqH61N4WcfouJAcAo2VIX5xccGBn6JIGBxY8/XVo9LczqFbKXLMSR4tcrL2JqzsEfaHHQA2+hXnELA5T7p+tbN+t8y37sR9S9k6nHANjk0MKZgVYapDlpnlY3xVzU4om7QxsEL0nBW46SWnUXq2SQ0XOtZTNggz3532wIl+6RTdEyuyYvrijDbjeolV0SYGCdUxirt8Bnmj3MvBQ14egKFRlyKjbgLnyMSPrTLmURRJWMrhXo7yB0hSNyfccQCoA+hQAvMJZrB2xCNKHNQfY8W1rZB3v8IP5P5UGEYejs4SzIkGIXs8NecAZOg0lxiFt0kn3J8o0I/c5ljhGUVdpu2Ei0jo43ZXjLmuP/YkMuJNKLzRdpsIbGibE2wc0G2G7VUFllifn0NFY2EpaiCYd7uZhBocSjIaA6EzAFqiMHvQ4=----ATTACHMENT:----NTgwNzA5MDIzNzE3OTcxNSA4ODQ3NDAyMjgxNzAxNjUgODMxNzI4MTc1ODU3NTY5MA==