doyolabs /
code-coverage-bridge
| 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\Bridge\CodeCoverage\Session; |
||
| 15 | |||
| 16 | use Doyo\Bridge\CodeCoverage\Driver\Dummy; |
||
| 17 | use Doyo\Bridge\CodeCoverage\Processor; |
||
| 18 | use Doyo\Bridge\CodeCoverage\TestCase; |
||
| 19 | use SebastianBergmann\CodeCoverage\Filter; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | class RemoteSession extends Session |
||
| 22 | { |
||
| 23 | const HEADER_SESSION_KEY = 'HTTP_DOYO_COVERAGE_SESSION'; |
||
| 24 | const HEADER_TEST_CASE_KEY = 'HTTP_DOYO_COVERAGE_TESTCASE'; |
||
| 25 | |||
| 26 | public static function startSession() |
||
| 27 | { |
||
| 28 | if (!isset($_SERVER[static::HEADER_SESSION_KEY])) { |
||
| 29 | return false; |
||
| 30 | } |
||
| 31 | |||
| 32 | $name = $_SERVER[static::HEADER_SESSION_KEY]; |
||
| 33 | $session = new static($name); |
||
| 34 | if (isset($_SERVER[static::HEADER_TEST_CASE_KEY])) { |
||
| 35 | $session->doStartSession(); |
||
| 36 | } else { |
||
| 37 | return false; |
||
| 38 | } |
||
| 39 | $session->save(); |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function init(array $config) |
||
| 45 | { |
||
| 46 | $filter = new Filter(); |
||
| 47 | if (isset($config['filterOptions'])) { |
||
| 48 | $filter->setWhitelistedFiles($config['filterOptions']['whitelistedFiles']); |
||
| 49 | } |
||
| 50 | |||
| 51 | $processor = new Processor(new Dummy(), $filter); |
||
| 52 | $codeCoverage = $processor->getCodeCoverage(); |
||
| 53 | if (isset($config['codeCoverageOptions'])) { |
||
| 54 | foreach ($config['codeCoverageOptions'] as $method => $option) { |
||
| 55 | $method = 'set'.ucfirst($method); |
||
| 56 | \call_user_func_array([$codeCoverage, $method], [$option]); |
||
| 57 | } |
||
| 58 | $processor->setCodeCoverageOptions($config['codeCoverageOptions']); |
||
| 59 | } |
||
| 60 | $this->setProcessor($processor); |
||
| 61 | $this->reset(); |
||
| 62 | } |
||
| 63 | |||
| 64 | public function doStartSession() |
||
| 65 | { |
||
| 66 | $name = $_SERVER[static::HEADER_TEST_CASE_KEY]; |
||
| 67 | $testCase = new TestCase($name); |
||
| 68 | $this->setTestCase($testCase); |
||
| 69 | |||
| 70 | try { |
||
| 71 | $this->start(); |
||
| 72 | register_shutdown_function([$this, 'shutdown']); |
||
| 73 | } catch (\Exception $e) { |
||
| 74 | $this->reset(); |
||
| 75 | $this->exceptions[] = $e; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
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