Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit afad962

Browse files
Fix HttpCallListener when Mink driver is not started yet
1 parent 78b29a4 commit afad962

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: php
22

3-
dist: trusty
3+
dist: xenial
44

55
addons:
66
chrome: stable

src/Context/BrowserContext.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function __construct($timeout = 1)
2525
*/
2626
public function closeBrowser()
2727
{
28-
$this->getSession()->stop();
28+
if ($this->getMink()->isSessionStarted()) {
29+
$this->getSession()->stop();
30+
}
2931
}
3032

3133
/**

src/HttpCall/HttpCallListener.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ public function afterStep(AfterStepTested $event)
5151
// For now to avoid modification on MinkContext
5252
// We add fallback on Mink
5353
try {
54-
$this->httpCallResultPool->store(
55-
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
56-
);
54+
if ($this->mink->getSession()->isStarted()) {
55+
$this->httpCallResultPool->store(
56+
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
57+
);
58+
}
5759
} catch (\LogicException $e) {
5860
// Mink has no response
5961
} catch (\Behat\Mink\Exception\DriverException $e) {

tests/features/browser.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
Feature: Browser Feature
22

3+
@javascript
4+
Scenario: Testing when scenario has no HTTP call
5+
Given I wait 0.1 seconds
6+
37
# If this scenario fails
48
# It's probably because your web environment is not properly setup
5-
# You will find the necessery help in README.md
9+
# You will find the necessary help in README.md
610
@javascript
711
Scenario: Testing simple web access
812
Given I am on "/index.html"

0 commit comments

Comments
 (0)