![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/phpgt/dom/test/phpunit/ |
<?php namespace Gt\Dom\Test; use Gt\Dom\HTMLDocument; use Gt\Dom\Test\Helper\Helper; use PHPUnit\Framework\TestCase; class TextTest extends TestCase { public function testIsElementContentWhitespace() { $document = new HTMLDocument(Helper::HTML_MORE); $firstChild = $document->body->firstChild; $this->assertTrue($firstChild->isElementContentWhitespace()); $h1 = $document->querySelector("h1"); $h1Child = $h1->firstChild; $this->assertFalse($h1Child->isElementContentWhitespace()); } public function testWholeText() { $document = new HTMLDocument(Helper::HTML_TEXT); $para = $document->querySelector("p"); // Remove the <strong> $para->childNodes[1]->remove(); // WholeText should contain all text up to the link. $textNode = $para->firstChild; $this->assertStringContainsString("Thru-hiking is great!", $textNode->wholeText); $this->assertStringContainsString(" However, ", $textNode->wholeText); } public function testSplitText() { $document = new HTMLDocument(Helper::HTML_TEXT); $para = $document->querySelector("p"); $textNode = $para->firstChild; $textNode->splitText(4); $this->assertEquals("Thru", $para->firstChild->textContent); $this->assertStringContainsString("-hiking is great!", $para->firstChild->nextSibling->textContent); } }