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

FileListSqlSupportTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testThatAllParserStatementsAreSupported() 0 13 1
A getProtectedStaticPropertyValue() 0 10 1
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