function LinkFieldTest::assertValidEntries

Same name in other branches
  1. 8.9.x core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertValidEntries()
  2. 10 core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertValidEntries()
  3. 11.x core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertValidEntries()

Asserts that valid URLs can be submitted.

@internal

Parameters

string $field_name: The field name.

array $valid_entries: An array of valid URL entries.

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

File

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

Class

LinkFieldTest
Tests link field widgets and formatters.

Namespace

Drupal\Tests\link\Functional

Code

protected function assertValidEntries(string $field_name, array $valid_entries) : void {
    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()
            ->statusMessageContains('entity_test ' . $id . ' has been created.', 'status');
        $this->assertSession()
            ->responseContains('"' . $string . '"');
    }
}

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