protected function WebformAssertLegacyTrait::assertNoUniqueText in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/src/Traits/WebformAssertLegacyTrait.php \Drupal\Tests\webform\Traits\WebformAssertLegacyTrait::assertNoUniqueText()
Passes if the text is found MORE THAN ONCE on the text version of the page.
The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
Parameters
string|\Drupal\Component\Render\MarkupInterface $text: Plain text to look for.
string $message: (optional) A message to display with the assertion. Do not translate messages with t(). If left blank, a default message will be displayed.
File
- tests/
src/ Traits/ WebformAssertLegacyTrait.php, line 212
Class
- WebformAssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\Tests\webform\TraitsCode
protected function assertNoUniqueText($text, $message = '') {
// Cast MarkupInterface objects to string.
$text = (string) $text;
$message = $message ?: "'{$text}' found more than once on the page";
$page_text = $this
->getSession()
->getPage()
->getText();
$nr_found = substr_count($page_text, $text);
$this
->assertGreaterThan(1, $nr_found, $message);
}