Conditions | 1 |
Paths | 1 |
Total Lines | 40 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function testConfigMergingFromDifferentSources() |
||
12 | { |
||
13 | $testFile = tempnam(sys_get_temp_dir(), 'test'); |
||
14 | $content = sprintf( |
||
15 | '<?php return ["event1" => [ new %s(%s::get()) ]];', |
||
16 | Action\PhpLinter::class, |
||
17 | Change\FullChangeSet::class |
||
18 | ); |
||
19 | $this->assertNotFalse(file_put_contents($testFile, $content)); |
||
20 | |||
21 | $cfg = new Config(); |
||
22 | $cfg->loadFromFile($testFile, new NullLogger()); |
||
23 | $cfg->loadFromArray( |
||
24 | [ |
||
25 | 'event2' => [ |
||
26 | new Action\PhpLinter(Change\FullChangeSet::get()), |
||
27 | ], |
||
28 | 'event1' => [ |
||
29 | new Action\RiskyFiles(Change\FullChangeSet::get(), ''), |
||
30 | new Action\ForbiddenFiles(Change\FullChangeSet::get(), ''), |
||
31 | ], |
||
32 | ], |
||
33 | new NullLogger() |
||
34 | ); |
||
35 | |||
36 | $this->assertSame( |
||
37 | ['event1', 'event2'], |
||
38 | array_keys($cfg->getAllEventActions()) |
||
39 | ); |
||
40 | $this->assertSame( |
||
41 | [Action\RiskyFiles::class, Action\ForbiddenFiles::class], |
||
42 | array_map('get_class', $cfg->getActionsForEvent('event1')) |
||
43 | ); |
||
44 | $this->assertSame( |
||
45 | [Action\PhpLinter::class], |
||
46 | array_map('get_class', $cfg->getActionsForEvent('event2')) |
||
47 | ); |
||
48 | |||
49 | $this->assertNotFalse(unlink($testFile)); |
||
50 | } |
||
51 | } |
||
52 |