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

Commit

Permalink
Fix HttpCallListener when Mink driver is not started yet
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-vauchel-webrivage committed Oct 9, 2020
1 parent 78b29a4 commit 788c4db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: php

dist: trusty
dist: bionic

addons:
chrome: stable
Expand Down
4 changes: 3 additions & 1 deletion src/Context/BrowserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function __construct($timeout = 1)
*/
public function closeBrowser()
{
$this->getSession()->stop();
if ($this->getMink()->isSessionStarted()) {
$this->getSession()->stop();
}
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/HttpCall/HttpCallListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public function afterStep(AfterStepTested $event)
// For now to avoid modification on MinkContext
// We add fallback on Mink
try {
$this->httpCallResultPool->store(
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
);
if ($this->mink->getSession()->isStarted()) {
$this->httpCallResultPool->store(
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
);
}
} catch (\LogicException $e) {
// Mink has no response
} catch (\Behat\Mink\Exception\DriverException $e) {
Expand Down
6 changes: 5 additions & 1 deletion tests/features/browser.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Feature: Browser Feature

@javascript
Scenario: Testing when scenario has no HTTP call
Given I wait 0.1 seconds

# If this scenario fails
# It's probably because your web environment is not properly setup
# You will find the necessery help in README.md
# You will find the necessary help in README.md
@javascript
Scenario: Testing simple web access
Given I am on "/index.html"
Expand Down

0 comments on commit 788c4db

Please sign in to comment.