function LinkFieldTest::assertValidEntries

Same name in other branches
  1. 9 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.

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->drupalPostForm('entity_test/add', $edit, t('Save'));
        preg_match('|entity_test/manage/(\\d+)|', $this->getUrl(), $match);
        $id = $match[1];
        $this->assertText(t('entity_test @id has been created.', [
            '@id' => $id,
        ]));
        $this->assertRaw('"' . $string . '"');
    }
}

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