protected function AssertLegacyTrait::assertNoText in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertNoText()
Passes if the page (with HTML stripped) does not contains the text.
Note that stripping HTML tags also removes their attributes, such as the values of text fields.
Parameters
string $text: Plain text to look for.
Deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use
- $this->assertSession()->responseNotContains() for non-HTML responses, like XML or Json.
- $this->assertSession()->pageTextNotContains() for HTML responses. Unlike the deprecated assertNoText(), the passed text should be HTML decoded, exactly as a human sees it in the browser.
262 calls to AssertLegacyTrait::assertNoText()
- AccessDeniedTest::testAccessDeniedCustomPageWithAccessDenied in core/
modules/ system/ tests/ src/ Functional/ System/ AccessDeniedTest.php - Tests that an inaccessible custom 403 page falls back to the default.
- AggregatorRenderingTest::testBlockLinks in core/
modules/ aggregator/ tests/ src/ Functional/ AggregatorRenderingTest.php - Adds a feed block to the page and checks its links.
- BaseFieldAccessTest::testProtectedField in core/
modules/ views/ tests/ src/ Functional/ Entity/ BaseFieldAccessTest.php - Test access to protected base fields.
- BasicAuthTest::testBasicAuth in core/
modules/ basic_auth/ tests/ src/ Functional/ BasicAuthTest.php - Test http basic authentication.
- BasicAuthTest::testUnauthorizedErrorMessage in core/
modules/ basic_auth/ tests/ src/ Functional/ BasicAuthTest.php - Tests if a comprehensive message is displayed when the route is denied.
1 method overrides AssertLegacyTrait::assertNoText()
- UncaughtExceptionTest::assertNoText in core/
tests/ Drupal/ FunctionalTests/ Bootstrap/ UncaughtExceptionTest.php - Passes if the page (with HTML stripped) does not contains the text.
File
- core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php, line 103
Class
- AssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\FunctionalTestsCode
protected function assertNoText($text) {
// Cast MarkupInterface to string.
$text = (string) $text;
$content_type = $this
->getSession()
->getResponseHeader('Content-type');
// In case of a Non-HTML response (example: XML) check the original
// response.
if (strpos($content_type, 'html') === FALSE) {
$this
->assertSession()
->responseNotContains($text);
}
else {
$this
->assertTextHelper($text);
}
}