1
|
|
|
<?php |
2
|
|
|
class SuricateTest extends \PHPUnit\Framework\TestCase |
3
|
|
|
{ |
4
|
|
|
public function testConfigFile() |
5
|
|
|
{ |
6
|
|
|
// Empty config files list at the beginning |
7
|
|
|
$object = new \Suricate\Suricate(); |
8
|
|
|
$reflectionClass = new ReflectionClass($object); |
9
|
|
|
$property = $reflectionClass->getProperty('configFile'); |
10
|
|
|
$property->setAccessible(true); |
11
|
|
|
$configFiles = $property->getValue($object); |
12
|
|
|
|
13
|
|
|
$this->assertEquals([], $configFiles); |
14
|
|
|
|
15
|
|
|
// single config file |
16
|
|
|
$object = new \Suricate\Suricate([], './tests/stubs/my-single-config.ini'); |
17
|
|
|
$reflectionClass = new ReflectionClass($object); |
18
|
|
|
$property = $reflectionClass->getProperty('configFile'); |
19
|
|
|
$property->setAccessible(true); |
20
|
|
|
$configFiles = $property->getValue($object); |
21
|
|
|
|
22
|
|
|
$this->assertEquals(['./tests/stubs/my-single-config.ini'], $configFiles); |
23
|
|
|
|
24
|
|
|
// multiple config file |
25
|
|
|
$object = new \Suricate\Suricate([], ['./tests/stubs/my-single-config.ini', './tests/stubs/another-config.ini']); |
26
|
|
|
$reflectionClass = new ReflectionClass($object); |
27
|
|
|
$property = $reflectionClass->getProperty('configFile'); |
28
|
|
|
$property->setAccessible(true); |
29
|
|
|
$configFiles = $property->getValue($object); |
30
|
|
|
|
31
|
|
|
$this->assertEquals(['./tests/stubs/my-single-config.ini', './tests/stubs/another-config.ini'], $configFiles); |
32
|
|
|
|
33
|
|
|
// non existent file |
34
|
|
|
$object = new \Suricate\Suricate([], ['./tests/stubs/my-single-config-unknown.ini', './tests/stubs/another-config.ini']); |
35
|
|
|
$reflectionClass = new ReflectionClass($object); |
36
|
|
|
$property = $reflectionClass->getProperty('configFile'); |
37
|
|
|
$property->setAccessible(true); |
38
|
|
|
$configFiles = $property->getValue($object); |
39
|
|
|
|
40
|
|
|
$this->assertEquals(['./tests/stubs/another-config.ini'], $configFiles); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
|