You are here

protected function LinkFieldTest::assertValidEntries in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertValidEntries()

Asserts that valid URLs can be submitted.

Parameters

string $field_name: The field name.

array $valid_entries: An array of valid URL entries.

1 call to LinkFieldTest::assertValidEntries()
LinkFieldTest::testURLValidation in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests link field URL validation.

File

core/modules/link/tests/src/Functional/LinkFieldTest.php, line 215

Class

LinkFieldTest
Tests link field widgets and formatters.

Namespace

Drupal\Tests\link\Functional

Code

protected function assertValidEntries($field_name, array $valid_entries) {
  foreach ($valid_entries as $uri => $string) {
    $edit = [
      "{$field_name}[0][uri]" => $uri,
    ];
    $this
      ->drupalGet('entity_test/add');
    $this
      ->submitForm($edit, 'Save');
    preg_match('|entity_test/manage/(\\d+)|', $this
      ->getUrl(), $match);
    $id = $match[1];
    $this
      ->assertSession()
      ->pageTextContains('entity_test ' . $id . ' has been created.');
    $this
      ->assertSession()
      ->responseContains('"' . $string . '"');
  }
}