You are here

public function MediaUiFunctionalTest::assertHelpTexts in Drupal 9

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

Asserts that the given texts are present exactly once.

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 479

Class

MediaUiFunctionalTest
Ensures that media UI works correctly.

Namespace

Drupal\Tests\media\Functional

Code

public function assertHelpTexts(array $texts, $selector = '') {
  $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);
    }
  }
}