Passed
Push — develop ( c404d0...7a63fa )
by Jens
08:21 queued 01:02
created

FeatureContext::setup()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 2
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use Behat\Behat\Context\Context;
4
use Behat\Behat\Context\SnippetAcceptingContext;
5
6
require_once __DIR__ . '/../../vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';
7
require_once __DIR__ . '/ApiContext.php';
8
9
/**
10
 * Defines application features from the specific context.
11
 */
12
class FeatureContext implements Context, SnippetAcceptingContext
0 ignored issues
show
Deprecated Code introduced by
The interface Behat\Behat\Context\SnippetAcceptingContext has been deprecated: will be removed in 4.0. Use --snippets-for CLI option instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

12
class FeatureContext implements Context, /** @scrutinizer ignore-deprecated */ SnippetAcceptingContext

This interface has been deprecated. The supplier of the interface has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the interface will be removed and what other interface to use instead.

Loading history...
13
{
14
    use \Commercetools\Core\ApiContext;
15
16
    protected static $coverage;
17
18
    /**
19
     * @BeforeSuite
20
     */
21
    public static function setup()
22
    {
23
        if (isset($_SERVER['BEHAT_COVERAGE']) && $_SERVER['BEHAT_COVERAGE'] == true) {
24
            $filter = new \PHP_CodeCoverage_Filter();
0 ignored issues
show
Bug introduced by
The type PHP_CodeCoverage_Filter 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...
25
            $filter->addDirectoryToBlacklist(__DIR__ . '/../vendor');
26
            $filter->addDirectoryToBlacklist(__DIR__ . '/../tests');
27
            $filter->addDirectoryToBlacklist(__DIR__ . '/../features');
28
            $filter->addDirectoryToWhitelist(__DIR__ . '/../src');
29
30
            static::$coverage = new \PHP_CodeCoverage(null, $filter);
0 ignored issues
show
Bug introduced by
The type PHP_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...
31
            static::$coverage->start('Behat Test');
32
        }
33
        date_default_timezone_set('UTC');
34
    }
35
36
37
    /**
38
     * @AfterSuite
39
     */
40
    public static function teardown()
41
    {
42
        if (isset($_SERVER['BEHAT_COVERAGE']) && $_SERVER['BEHAT_COVERAGE'] == true) {
43
            static::$coverage->stop();
44
45
            echo 'Generating code coverage report in Clover XML format ... ';
46
            $writer = new \PHP_CodeCoverage_Report_Clover();
0 ignored issues
show
Bug introduced by
The type PHP_CodeCoverage_Report_Clover 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...
47
            $writer->process(static::$coverage, __DIR__ . '/../../build/logs/behat-clover.cov');
48
            echo 'done' . PHP_EOL;
49
50
//            echo 'Generating code coverage report in HTML format ... ';
51
//            $writer = new PHP_CodeCoverage_Report_HTML();
52
//            $writer->process(static::$coverage, __DIR__ . "/../../build/behat/coverage");
53
//            echo 'done' . PHP_EOL;
54
        }
55
    }
56
}
57