From e75dd2bcbd28056549810261a341ad2d030055bd Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 2 Dec 2024 22:04:11 +0200 Subject: [PATCH] Added test for "getText" method --- tests/Basic/ContentTest.php | 15 +++++++++++++++ web-fixtures/index.html | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/tests/Basic/ContentTest.php b/tests/Basic/ContentTest.php index f8b2d86..5cd6706 100644 --- a/tests/Basic/ContentTest.php +++ b/tests/Basic/ContentTest.php @@ -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: + * -
gets replaced with a space + * - spaces around the text are trimmed + * -   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')); diff --git a/web-fixtures/index.html b/web-fixtures/index.html index cc8c821..dd11a0f 100644 --- a/web-fixtures/index.html +++ b/web-fixtures/index.html @@ -36,6 +36,10 @@

Extremely useless page

el4
+

line 2: text inside + div + line 3:
+