菜谱项目

ParserFactoryTest.php 1.0KB

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