Skip to content

Commit

Permalink
Merge pull request #99 from aik099/get-text-test
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 authored Dec 3, 2024
2 parents 88ea651 + e75dd2b commit 387f66f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/Basic/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ public function testOuterHtml(): void
);
}

public function testGetText(): void
{
$this->getSession()->visit($this->pathTo('/index.html'));

$element = $this->getAssertSession()->elementExists('css', '.get-text-trim');

/*
* Tests, these things:
* - <br> gets replaced with a space
* - spaces around the text are trimmed
* - &nbsp; are replaced with " " (non-breakable space) and then with " " (regular space)
*/
$this->assertEquals('line 2: text inside div line 3:', $element->getText());
}

public function testDumpingEmptyElements(): void
{
$this->getSession()->visit($this->pathTo('/index.html'));
Expand Down
4 changes: 4 additions & 0 deletions web-fixtures/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ <h1>Extremely useless page</h1>

<div class="sub">el4</div>

<div class="get-text-trim"><br/>line 2: text <strong>inside</strong>
div
line&nbsp;3:<br/></div>

</div>

<footer>
Expand Down

0 comments on commit 387f66f

Please sign in to comment.