doyolabs /
phpspec-code-coverage
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the doyo/code-coverage project. |
||
| 5 | * |
||
| 6 | * (c) Anthonius Munthi <[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 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Doyo\PhpSpec\CodeCoverage; |
||
| 15 | |||
| 16 | use Doyo\Bridge\CodeCoverage\ContainerFactory; |
||
|
0 ignored issues
–
show
|
|||
| 17 | use Doyo\PhpSpec\CodeCoverage\Listener\CoverageListener; |
||
| 18 | use PhpSpec\Extension as ExtensionInterface; |
||
| 19 | use PhpSpec\ServiceContainer; |
||
| 20 | use Symfony\Component\Console\Input\InputInterface; |
||
| 21 | use Symfony\Component\Console\Input\InputOption; |
||
| 22 | |||
| 23 | class Extension implements ExtensionInterface |
||
| 24 | { |
||
| 25 | public function load(ServiceContainer $container, array $params) |
||
| 26 | { |
||
| 27 | $this->addCoverageOptions($container); |
||
| 28 | |||
| 29 | /** @var InputInterface $input */ |
||
| 30 | $input = $container->get('console.input'); |
||
| 31 | |||
| 32 | if (false === $input->hasParameterOption(['--coverage'], false)) { |
||
| 33 | return; |
||
| 34 | } |
||
| 35 | |||
| 36 | $container->define('doyo.coverage.container', function ($container) use ($params) { |
||
| 37 | $coverageContainer = (new ContainerFactory($params, true))->getContainer(); |
||
| 38 | $input = $container->get('console.input'); |
||
| 39 | $output = $container->get('console.output'); |
||
| 40 | $coverageContainer->set('console.input', $input); |
||
| 41 | $coverageContainer->set('console.output', $output); |
||
| 42 | |||
| 43 | return $coverageContainer; |
||
| 44 | }); |
||
| 45 | |||
| 46 | $container->define('doyo.coverage.listener', function ($container) { |
||
| 47 | $coverageContainer = $container->get('doyo.coverage.container'); |
||
| 48 | $coverage = $coverageContainer->get('coverage'); |
||
| 49 | |||
| 50 | return new CoverageListener($coverage); |
||
| 51 | }, ['event_dispatcher.listeners']); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function addCoverageOptions(ServiceContainer $container) |
||
| 55 | { |
||
| 56 | /** @var \PhpSpec\Console\Command\RunCommand $command */ |
||
| 57 | $command = $container->get('console.commands.run'); |
||
| 58 | $command->addOption( |
||
| 59 | 'coverage', |
||
| 60 | null, |
||
| 61 | InputOption::VALUE_NONE, |
||
| 62 | 'Run phpspec with code coverage' |
||
| 63 | ); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
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