Skip to content

Commit de3c660

Browse files
committed
dump context extends raw context
1 parent cd7fe16 commit de3c660

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Behat/ContextDump.php src/Behat/DumpContext.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
namespace Atk4\Ui\Behat;
66

7+
use Behat\Behat\Context\Context as BehatContext;
78
use Behat\Behat\Hook\Scope\AfterStepScope;
8-
use Behat\Testwork\Tester\Result\TestResult;
9+
use Behat\MinkExtension\Context\RawMinkContext;
910

10-
/**
11-
* Dump page data when failed.
12-
*/
13-
class ContextDump extends Context
11+
class DumpContext extends RawMinkContext implements BehatContext
1412
{
1513
/**
1614
* Dump current page data when step failed for CI.
@@ -19,16 +17,18 @@ class ContextDump extends Context
1917
*/
2018
public function dumpPageAfterFailedStep(AfterStepScope $event): void
2119
{
20+
$session = $this->getMink()->getSession();;
21+
2222
if ($event->getTestResult()->getResultCode() === TestResult::FAILED) {
23-
if ($this->getSession()->getDriver() instanceof \Behat\Mink\Driver\Selenium2Driver) {
23+
if ($session->getDriver() instanceof \Behat\Mink\Driver\Selenium2Driver) {
2424
echo 'Dump of failed step:' . "\n";
25-
echo 'Current page URL: ' . $this->getSession()->getCurrentUrl() . "\n";
25+
echo 'Current page URL: ' . $session->getCurrentUrl() . "\n";
2626
global $dumpPageCount;
2727
if (++$dumpPageCount <= 1) { // prevent huge tests output
2828
// upload screenshot here if needed in the future
29-
// $screenshotData = $this->getSession()->getScreenshot();
29+
// $screenshotData = $session->getScreenshot();
3030
// echo 'Screenshot URL: ' . $screenshotUrl . "\n";
31-
echo 'Page source: ' . $this->getSession()->getPage()->getContent() . "\n";
31+
echo 'Page source: ' . $session->getPage()->getContent() . "\n";
3232
} else {
3333
echo 'Page source: Source code is dumped for the first failed step only.' . "\n";
3434
}

0 commit comments

Comments
 (0)