Issues (142)

Context/CoverageContext.php (4 issues)

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\Context;
15
16
use Behat\Behat\Context\Context;
0 ignored issues
show
The type Behat\Behat\Context\Context was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use SebastianBergmann\CodeCoverage\CodeCoverage;
0 ignored issues
show
The type SebastianBergmann\CodeCoverage\CodeCoverage was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Webmozart\Assert\Assert;
0 ignored issues
show
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
class CoverageContext implements Context
21
{
22
    /**
23
     * @var CodeCoverage
24
     */
25
    private $coverage;
26
27
    /**
28
     * @Given I read coverage report :file
29
     *
30
     * @param string $file
31
     */
32
    public function iReadPhpCoverageReport($file)
33
    {
34
        $file = getcwd().\DIRECTORY_SEPARATOR.$file;
35
36
        /** @var CodeCoverage $coverage */
37
        include $file;
38
39
        $this->coverage = $coverage;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $coverage seems to be never defined.
Loading history...
40
    }
41
42
    /**
43
     * @Then file :file line :line should covered
44
     *
45
     * @param mixed      $file
46
     * @param mixed|null $line
47
     */
48
    public function fileAtLineShouldCovered($file, $line = null)
49
    {
50
        $data = $this->coverage->getData();
51
        $file = getcwd().\DIRECTORY_SEPARATOR.$file;
52
53
        Assert::true(isset($data[$file]));
54
        if (null === $line) {
55
            return;
56
        }
57
58
        Assert::true(isset($data[$file][$line]));
59
        Assert::notEmpty($data[$file][$line]);
60
    }
61
}
62