Completed
Pull Request — master (#30)
by Christian
02:15
created

testThatAllParserStatementsAreSupported()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace uuf6429\ElderBrother\Change;
4
5
use SqlParser\Parser as SqlParser;
6
7
class FileListSqlSupportTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testThatAllParserStatementsAreSupported()
10
    {
11
        $sqlParserStatements = array_unique(array_filter(array_values(SqlParser::$STATEMENT_PARSERS)));
12
        sort($sqlParserStatements);
13
14
        $supportedStatements = call_user_func_array(
15
            'array_merge',
16
            $this->getProtectedStaticPropertyValue(FileList::class, 'statementTypes')
17
        );
18
        sort($supportedStatements);
19
20
        $this->assertEquals($sqlParserStatements, $supportedStatements);
21
    }
22
23
    /**
24
     * @param string $class
25
     * @param string $property
26
     * @return mixed
27
     */
28
    protected function getProtectedStaticPropertyValue($class, $property)
29
    {
30
        $refClass   = new \ReflectionClass($class);
31
        $refProperty = $refClass->getProperty($property);
32
        $refProperty->setAccessible(true);
33
        $value = $refProperty->getValue();
34
        $refProperty->setAccessible(false);
35
36
        return $value;
37
    }
38
}
39