ParserFactoryTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. class ParserFactoryTest extends \PHPUnit\Framework\TestCase
  6. {
  7. /** @dataProvider provideTestCreate */
  8. public function testCreate($kind, $lexer, $expected) {
  9. $this->assertInstanceOf($expected, (new ParserFactory)->create($kind, $lexer));
  10. }
  11. public function provideTestCreate() {
  12. $lexer = new Lexer();
  13. return [
  14. [
  15. ParserFactory::PREFER_PHP7, $lexer,
  16. Parser\Multiple::class
  17. ],
  18. [
  19. ParserFactory::PREFER_PHP5, null,
  20. Parser\Multiple::class
  21. ],
  22. [
  23. ParserFactory::ONLY_PHP7, null,
  24. Parser\Php7::class
  25. ],
  26. [
  27. ParserFactory::ONLY_PHP5, $lexer,
  28. Parser\Php5::class
  29. ]
  30. ];
  31. }
  32. }