Skip to content

Commit 387f66f

Browse files
authored
Merge pull request #99 from aik099/get-text-test
2 parents 88ea651 + e75dd2b commit 387f66f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/Basic/ContentTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ public function testOuterHtml(): void
2121
);
2222
}
2323

24+
public function testGetText(): void
25+
{
26+
$this->getSession()->visit($this->pathTo('/index.html'));
27+
28+
$element = $this->getAssertSession()->elementExists('css', '.get-text-trim');
29+
30+
/*
31+
* Tests, these things:
32+
* - <br> gets replaced with a space
33+
* - spaces around the text are trimmed
34+
* - &nbsp; are replaced with " " (non-breakable space) and then with " " (regular space)
35+
*/
36+
$this->assertEquals('line 2: text inside div line 3:', $element->getText());
37+
}
38+
2439
public function testDumpingEmptyElements(): void
2540
{
2641
$this->getSession()->visit($this->pathTo('/index.html'));

web-fixtures/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ <h1>Extremely useless page</h1>
3636

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

39+
<div class="get-text-trim"><br/>line 2: text <strong>inside</strong>
40+
div
41+
line&nbsp;3:<br/></div>
42+
3943
</div>
4044

4145
<footer>

0 commit comments

Comments
 (0)