Completed
Push — develop ( e0343e...7d04f4 )
by Daniel
08:13
created

FeatureContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 40
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A removeAcceptHeaderAfterRequest() 0 4 2
A removeAcceptHeaderBeforeScenario() 0 3 1
1
<?php
2
3
use Behat\Behat\Context\Context;
4
use Behat\Behat\Hook\Scope\AfterStepScope;
5
use Behatch\HttpCall\Request;
6
7
/**
8
 * Defines application features from the specific context.
9
 */
10
class FeatureContext implements Context
11
{
12
    /**
13
     * @var Request\BrowserKit
14
     */
15
    private $request;
16
17
    /**
18
     * Initializes context.
19
     *
20
     * Every scenario gets its own context instance.
21
     * You can also pass arbitrary arguments to the
22
     * context constructor through behat.yml.
23
     * @param Request $request
24
     */
25
    public function __construct(Request $request)
26
    {
27
        $this->request = $request;
0 ignored issues
show
Documentation Bug introduced by
It seems like $request of type Behatch\HttpCall\Request is incompatible with the declared type Behatch\HttpCall\Request\BrowserKit of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
    }
29
30
    /**
31
     * Sets the default Accept HTTP header to null (workaround to artificially remove it).
32
     * @AfterStep
33
     * @param AfterStepScope $event
34
     */
35
    public function removeAcceptHeaderAfterRequest(AfterStepScope $event)
36
    {
37
        if (preg_match('/^I send a "[A-Z]+" request to ".+"/', $event->getStep()->getText())) {
38
            $this->request->setHttpHeader('Accept', null);
39
        }
40
    }
41
42
    /**
43
     * Sets the default Accept HTTP header to null (workaround to artificially remove it).
44
     *
45
     * @BeforeScenario
46
     */
47
    public function removeAcceptHeaderBeforeScenario()
48
    {
49
        $this->request->setHttpHeader('Accept', null);
50
    }
51
}
52