1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace RMiller\PhpSpecRunExtension; |
4
|
|
|
|
5
|
|
|
use PhpSpec\Extension\ExtensionInterface; |
6
|
|
|
use PhpSpec\ServiceContainer; |
7
|
|
|
use RMiller\PhpSpecRunExtension\Process\CachingExecutableFinder; |
8
|
|
|
use RMiller\PhpSpecRunExtension\Process\CommandRunner\CliFunctionChecker; |
9
|
|
|
use RMiller\PhpSpecRunExtension\Process\CommandRunner\PassthruCommandRunner; |
10
|
|
|
use RMiller\PhpSpecRunExtension\Process\CommandRunner\PcntlCommandRunner; |
11
|
|
|
use RMiller\PhpSpecRunExtension\Process\RunRunner\CompositeRunRunner; |
12
|
|
|
use RMiller\PhpSpecRunExtension\Process\RunRunner\PlatformSpecificRunRunner; |
13
|
|
|
use Symfony\Component\Process\PhpExecutableFinder; |
14
|
|
|
|
15
|
|
|
class PhpSpecRunExtension implements ExtensionInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @param ServiceContainer $container |
19
|
|
|
*/ |
20
|
|
|
public function load(ServiceContainer $container) |
21
|
|
|
{ |
22
|
|
|
$container->setShared('rmiller.run_runner', function ($c) { |
23
|
|
|
|
24
|
|
|
$params = $c->getParam('rerunner', []); |
25
|
|
|
$phpspecPath = isset($params['path']) ? $params['path'] : 'bin/phpspec'; |
26
|
|
|
$phpspecConfig = isset($params['config']) ? $params['config'] : null; |
27
|
|
|
|
28
|
|
|
return new CompositeRunRunner([ |
29
|
|
|
new PlatformSpecificRunRunner( |
30
|
|
|
new PcntlCommandRunner($c->get('rmiller.run.function_checker')), |
31
|
|
|
$c->get('rmiller.run.caching_executable_finder'), |
32
|
|
|
$phpspecPath, |
33
|
|
|
$phpspecConfig |
34
|
|
|
), |
35
|
|
|
new PlatformSpecificRunRunner( |
36
|
|
|
new PassthruCommandRunner($c->get('rmiller.run.function_checker')), |
37
|
|
|
$c->get('rmiller.run.caching_executable_finder'), |
38
|
|
|
$phpspecPath, |
39
|
|
|
$phpspecConfig |
40
|
|
|
) |
41
|
|
|
]); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
$container->setShared('rmiller.run.function_checker', function ($c) { |
45
|
|
|
return new CliFunctionChecker($c->get('rmiller.run.caching_executable_finder')); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
$container->setShared('rmiller.run.caching_executable_finder', function () { |
49
|
|
|
return new CachingExecutableFinder(new PhpExecutableFinder()); |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
$container->setShared('console_event_dispatcher.listeners.run_runner', function ($c) { |
53
|
|
|
$params = $c->getParam('rerunner', []); |
54
|
|
|
$commands = isset($params['commands']) ? $params['commands'] : ['describe']; |
55
|
|
|
|
56
|
|
|
return new CommandSubscriber( |
57
|
|
|
$c->get('rmiller.run_runner'), |
58
|
|
|
$c->get('console.io'), |
59
|
|
|
$commands |
60
|
|
|
); |
61
|
|
|
}); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|