function MediaUiFunctionalTest::assertHelpTexts

Same name in other branches
  1. 8.9.x core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::assertHelpTexts()

Asserts that the given texts are present exactly once.

@internal

Parameters

string[] $texts: A list of the help texts to check.

string $selector: (optional) The selector to search.

1 call to MediaUiFunctionalTest::assertHelpTexts()
MediaUiFunctionalTest::testMediaReferenceWidget in core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php
Tests the default autocomplete widgets for media reference fields.

File

core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php, line 496

Class

MediaUiFunctionalTest
Ensures that media UI works correctly.

Namespace

Drupal\Tests\media\Functional

Code

public function assertHelpTexts(array $texts, string $selector = '') : void {
    $assert_session = $this->assertSession();
    foreach ($texts as $text) {
        // We only want to escape single quotes, so use str_replace() rather than
        // addslashes().
        $text = str_replace("'", "\\'", $text);
        if ($selector) {
            $assert_session->elementsCount('css', $selector . ":contains('{$text}')", 1);
        }
        else {
            $assert_session->pageTextContains($text);
        }
    }
}

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