comparison vendor/nikic/php-parser/test/PhpParser/ParserFactoryTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 5fb285c0d0e3
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace PhpParser;
4
5 /* This test is very weak, because PHPUnit's assertEquals assertion is way too slow dealing with the
6 * large objects involved here. So we just do some basic instanceof tests instead. */
7 class ParserFactoryTest extends \PHPUnit_Framework_TestCase {
8 /** @dataProvider provideTestCreate */
9 public function testCreate($kind, $lexer, $expected) {
10 $this->assertInstanceOf($expected, (new ParserFactory)->create($kind, $lexer));
11 }
12
13 public function provideTestCreate() {
14 $lexer = new Lexer();
15 return [
16 [
17 ParserFactory::PREFER_PHP7, $lexer,
18 'PhpParser\Parser\Multiple'
19 ],
20 [
21 ParserFactory::PREFER_PHP5, null,
22 'PhpParser\Parser\Multiple'
23 ],
24 [
25 ParserFactory::ONLY_PHP7, null,
26 'PhpParser\Parser\Php7'
27 ],
28 [
29 ParserFactory::ONLY_PHP5, $lexer,
30 'PhpParser\Parser\Php5'
31 ]
32 ];
33 }
34 }