ParserFactoryTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser;
  3. /* This test is very weak, because PHPUnit's assertEquals assertion is way too slow dealing with the
  4. * large objects involved here. So we just do some basic instanceof tests instead. */
  5. use PHPUnit\Framework\TestCase;
  6. class ParserFactoryTest extends TestCase
  7. {
  8. /** @dataProvider provideTestCreate */
  9. public function testCreate($kind, $lexer, $expected) {
  10. $this->assertInstanceOf($expected, (new ParserFactory)->create($kind, $lexer));
  11. }
  12. public function provideTestCreate() {
  13. $lexer = new Lexer();
  14. return [
  15. [
  16. ParserFactory::PREFER_PHP7, $lexer,
  17. Parser\Multiple::class
  18. ],
  19. [
  20. ParserFactory::PREFER_PHP5, null,
  21. Parser\Multiple::class
  22. ],
  23. [
  24. ParserFactory::ONLY_PHP7, null,
  25. Parser\Php7::class
  26. ],
  27. [
  28. ParserFactory::ONLY_PHP5, $lexer,
  29. Parser\Php5::class
  30. ]
  31. ];
  32. }
  33. }