ParserFactoryTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2023 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Psy\Test;
  11. use PhpParser\ParserFactory as OriginalParserFactory;
  12. use Psy\ParserFactory;
  13. /**
  14. * @group isolation-fail
  15. */
  16. class ParserFactoryTest extends \PHPUnit\Framework\TestCase
  17. {
  18. public function testGetPossibleKinds()
  19. {
  20. $kinds = ParserFactory::getPossibleKinds();
  21. $this->assertContains(ParserFactory::PREFER_PHP7, $kinds);
  22. foreach ($kinds as $kind) {
  23. $this->assertTrue(\defined("Psy\\ParserFactory::$kind"));
  24. }
  25. }
  26. public function testGetDefaultKind()
  27. {
  28. $factory = new ParserFactory();
  29. if (!\class_exists(OriginalParserFactory::class)) {
  30. $this->assertNull($factory->getDefaultKind());
  31. return;
  32. }
  33. $this->assertSame(ParserFactory::ONLY_PHP7, $factory->getDefaultKind());
  34. }
  35. public function testCreateParser()
  36. {
  37. $factory = new ParserFactory();
  38. $parser = $factory->createParser();
  39. $this->assertInstanceOf(\PhpParser\Parser\Php7::class, $parser);
  40. }
  41. }