Skip to content

Commit 0b28401

Browse files
authored
Merge pull request #20 from elbformat/fix-tag-content-trim
Fix comparing tag content to trimmed string
2 parents 2bda79d + fc62256 commit 0b28401

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Context/BrowserContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ protected function mustContainTag(string $tagName, array $attr = [], ?string $co
369369
$content = trim($content);
370370
/** @var DOMElement $elem */
371371
foreach ($elements as $elem) {
372-
if ($this->strComp->stringEquals($elem->textContent, $content)) {
372+
if ($this->strComp->stringEquals(trim($elem->textContent), $content)) {
373373
return null;
374374
}
375375
}

tests/Context/BrowserContextTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ public function testISeeATagWithContent(): void
355355
$this->browserContext->iSeeATag('a', $table, 'Hello World');
356356
}
357357

358+
public function testISeeATagWithContentComplex(): void
359+
{
360+
$this->setDom('<a href="/test"> <span> Hello World </span> <span> </span> </a>');
361+
$table = new TableNode([0 => ['href', '/test']]);
362+
$this->expectNotToPerformAssertions();
363+
$this->browserContext->iSeeATag('a', $table, 'Hello World');
364+
}
365+
358366
public function testISeeATagFails(): void
359367
{
360368
$this->setDom('<a href="/test">Hello World</a>');

0 commit comments

Comments
 (0)