function AssertContentTraitTest::testGetTextContent

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\AssertContentTraitTest::testGetTextContent()
  2. 8.9.x core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\AssertContentTraitTest::testGetTextContent()
  3. 10 core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\AssertContentTraitTest::testGetTextContent()

@covers ::getTextContent

File

core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php, line 21

Class

AssertContentTraitTest
@coversDefaultClass <a href="/api/drupal/core%21tests%21Drupal%21KernelTests%21AssertContentTrait.php/trait/AssertContentTrait/11.x" title="Provides test methods to assert content." class="local">\Drupal\KernelTests\AssertContentTrait</a> @group Test

Namespace

Drupal\Tests\Core\Test

Code

public function testGetTextContent() : void {
    $raw_content = <<<EOT

<Head>
<style>
@import url("foo.css");
</style>
</head>
<body>
bar
</body>
EOT;
    $this->setRawContent($raw_content);
    $this->assertStringNotContainsString('foo', $this->getTextContent());
    $this->assertStringNotContainsString('<body>', $this->getTextContent());
    $this->assertStringContainsString('bar', $this->getTextContent());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.