Passed
Push — develop ( 7a63fa...30cd04 )
by Jens
09:41
created

FeatureContext   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 37
rs 10
c 0
b 0
f 0
1
<?php
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
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();
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);
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();
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