Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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; |
||
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 | } |
||
52 |