File: ParserFactoryTest.php

package info (click to toggle)
php-parser 3.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,940 kB
  • sloc: php: 14,410; yacc: 1,791; makefile: 23; sh: 4
file content (37 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace PhpParser;

/* This test is very weak, because PHPUnit's assertEquals assertion is way too slow dealing with the
 * large objects involved here. So we just do some basic instanceof tests instead. */
use PHPUnit\Framework\TestCase;

class ParserFactoryTest extends TestCase
{
    /** @dataProvider provideTestCreate */
    public function testCreate($kind, $lexer, $expected) {
        $this->assertInstanceOf($expected, (new ParserFactory)->create($kind, $lexer));
    }

    public function provideTestCreate() {
        $lexer = new Lexer();
        return [
            [
                ParserFactory::PREFER_PHP7, $lexer,
                'PhpParser\Parser\Multiple'
            ],
            [
                ParserFactory::PREFER_PHP5, null,
                'PhpParser\Parser\Multiple'
            ],
            [
                ParserFactory::ONLY_PHP7, null,
                'PhpParser\Parser\Php7'
            ],
            [
                ParserFactory::ONLY_PHP5, $lexer,
                'PhpParser\Parser\Php5'
            ]
        ];
    }
}