You are here

abstract class AbstractHandlerTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php \Symfony\Component\CssSelector\Tests\Parser\Handler\AbstractHandlerTest

@author Jean-François Simon <contact@jfsimon.fr>

Hierarchy

  • class \Symfony\Component\CssSelector\Tests\Parser\Handler\AbstractHandlerTest extends \Symfony\Component\CssSelector\Tests\Parser\Handler\PHPUnit_Framework_TestCase

Expanded class hierarchy of AbstractHandlerTest

File

vendor/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php, line 21

Namespace

Symfony\Component\CssSelector\Tests\Parser\Handler
View source
abstract class AbstractHandlerTest extends \PHPUnit_Framework_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);
  }
  public abstract function getHandleValueTestData();
  public abstract function getDontHandleValueTestData();
  protected abstract 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));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractHandlerTest::assertRemainingContent protected function
AbstractHandlerTest::assertStreamEmpty protected function
AbstractHandlerTest::generateHandler abstract protected function 6
AbstractHandlerTest::getDontHandleValueTestData abstract public function 6
AbstractHandlerTest::getHandleValueTestData abstract public function 6
AbstractHandlerTest::testDontHandleValue public function @dataProvider getDontHandleValueTestData
AbstractHandlerTest::testHandleValue public function @dataProvider getHandleValueTestData 1