Skip to content

Commit 038ee12

Browse files
committed
[bug] use response crawler for dumping elements
Fixes broken panther tests.
1 parent 256c9be commit 038ee12

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

src/Browser/Response/HtmlResponse.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Zenstruck\Browser\Response;
44

5-
use Behat\Mink\Element\NodeElement;
65
use Symfony\Component\DomCrawler\Crawler;
76
use Symfony\Component\VarDumper\VarDumper;
87
use Zenstruck\Browser\Response;
@@ -31,15 +30,14 @@ final public function dump(?string $selector = null): void
3130
return;
3231
}
3332

34-
$elements = $this->session()->getPage()->findAll('css', $selector);
35-
$elements = \array_map(static fn(NodeElement $node) => $node->getHtml(), $elements);
33+
$elements = $this->crawler()->filter($selector);
3634

37-
if (empty($elements)) {
35+
if (0 === $elements->count()) {
3836
throw new \RuntimeException("Element \"{$selector}\" not found.");
3937
}
4038

41-
foreach ($elements as $element) {
42-
VarDumper::dump($element);
43-
}
39+
$elements->each(function(Crawler $node) {
40+
VarDumper::dump($node->html());
41+
});
4442
}
4543
}

tests/PantherBrowserTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,6 @@ public function cannot_follow_invisible_link(): void
187187
;
188188
}
189189

190-
/**
191-
* @test
192-
*/
193-
public function can_dump_html_element(): void
194-
{
195-
$this->markTestIncomplete('TODO: fix.');
196-
}
197-
198-
/**
199-
* @test
200-
*/
201-
public function if_dump_selector_matches_multiple_elements_all_are_dumped(): void
202-
{
203-
$this->markTestIncomplete('TODO: fix.');
204-
}
205-
206190
protected function browser(): PantherBrowser
207191
{
208192
return $this->pantherBrowser();

0 commit comments

Comments
 (0)