function MediaLibraryTestBase::waitForNoText

Same name in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::waitForNoText()
  2. 10 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::waitForNoText()
  3. 11.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::waitForNoText()

Asserts that text does not appear on page after a wait.

@todo replace with whatever gets added in https://www.drupal.org/node/3061852

Parameters

string $text: The text that should not be on the page.

int $timeout: Timeout in milliseconds, defaults to 10000.

7 calls to MediaLibraryTestBase::waitForNoText()
EntityReferenceWidgetTest::testWidget in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests that the Media library's widget works as expected.
MediaLibraryTestBase::pressInsertSelected in core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php
Presses the modal's "Insert selected" button.
MediaOverviewTest::testAdministrationPage in core/modules/media_library/tests/src/FunctionalJavascript/MediaOverviewTest.php
Tests that the Media Library's administration page works as expected.
WidgetOEmbedTest::testWidgetOEmbedAdvancedUi in core/modules/media_library/tests/src/FunctionalJavascript/WidgetOEmbedTest.php
Tests that oEmbed media can be added in the widget's advanced UI.
WidgetUploadTest::testWidgetUpload in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the Media library's widget works as expected.

... See full list

File

core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php, line 79

Class

MediaLibraryTestBase
Base class for functional tests of Media Library functionality.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function waitForNoText($text, $timeout = 10000) {
    $page = $this->getSession()
        ->getPage();
    $result = $page->waitFor($timeout / 1000, function ($page) use ($text) {
        $actual = preg_replace('/\\s+/u', ' ', $page->getText());
        $regex = '/' . preg_quote($text, '/') . '/ui';
        return (bool) (!preg_match($regex, $actual));
    });
    $this->assertNotEmpty($result, "\"{$text}\" was found but shouldn't be there.");
}

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