Security update for Core, with self-updated composer
[yaffs-website] / vendor / nikic / php-parser / test / PhpParser / ParserFactoryTest.php
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 }