|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of CaptainHook |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sebastian Feldmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace CaptainHook\App\Runner\Config; |
|
13
|
|
|
|
|
14
|
|
|
use CaptainHook\App\Config\Mockery as ConfigMockery; |
|
15
|
|
|
use CaptainHook\App\Config; |
|
16
|
|
|
use CaptainHook\App\Console\IO\Mockery as IOMockery; |
|
17
|
|
|
use CaptainHook\App\Mockery as CHMockery; |
|
18
|
|
|
use Exception; |
|
19
|
|
|
use org\bovigo\vfs\vfsStream; |
|
20
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class CreatorTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
use ConfigMockery; |
|
25
|
|
|
use IOMockery; |
|
26
|
|
|
use CHMockery; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Tests Creator::run |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testFailConfigFileExists(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->expectException(Exception::class); |
|
34
|
|
|
|
|
35
|
|
|
$config = $this->createConfigMock(true); |
|
36
|
|
|
$io = $this->createIOMock(); |
|
37
|
|
|
$io->method('ask')->will($this->onConsecutiveCalls('y', 'y', '\\Foo\\Bar', 'y', 'n')); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
$runner = new Creator($io, $config); |
|
40
|
|
|
$runner->advanced(true) |
|
41
|
|
|
->run(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Tests Creator::run |
|
46
|
|
|
* |
|
47
|
|
|
* Check if a previously defined configuration will not be deleted if we extend the configuration. |
|
48
|
|
|
* |
|
49
|
|
|
* @throws \Exception |
|
50
|
|
|
*/ |
|
51
|
|
|
public function testConfigureFileExtend(): void |
|
52
|
|
|
{ |
|
53
|
|
|
$configFileContentBefore = '{"pre-commit": {"enabled": false,"actions": [{"action": "phpunit"}]}}'; |
|
54
|
|
|
|
|
55
|
|
|
$configDir = vfsStream::setup('root', null, ['captainhook.json' => $configFileContentBefore]); |
|
56
|
|
|
$configFile = $configDir->url() . '/captainhook.json'; |
|
57
|
|
|
$config = Config\Factory::create($configFile); |
|
58
|
|
|
|
|
59
|
|
|
$io = $this->createIOMock(); |
|
60
|
|
|
$io->method('ask')->will($this->onConsecutiveCalls('y', 'y', '\\Foo\\Bar', 'y', 'n')); |
|
61
|
|
|
$io->expects($this->once())->method('askAndValidate')->willReturn('foo:bar'); |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
$runner = new Creator($io, $config); |
|
64
|
|
|
$runner->extend(true) |
|
65
|
|
|
->advanced(true) |
|
66
|
|
|
->run(); |
|
67
|
|
|
|
|
68
|
|
|
$configFileContentAfter = $configDir->getChild('captainhook.json')->getContent(); |
|
|
|
|
|
|
69
|
|
|
$this->assertFileExists($configFile); |
|
70
|
|
|
$this->assertStringContainsString('pre-commit', $configFileContentAfter); |
|
71
|
|
|
$this->assertStringContainsString('pre-push', $configFileContentAfter); |
|
72
|
|
|
$this->assertStringContainsString('phpunit', $configFileContentAfter); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths