function LinkFieldTest::assertInvalidEntries

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

Asserts that invalid URLs cannot be submitted.

Parameters

string $field_name: The field name.

array $invalid_entries: An array of invalid URL entries.

2 calls to LinkFieldTest::assertInvalidEntries()
LinkFieldTest::testURLValidation in core/modules/link/tests/src/Functional/LinkFieldTest.php
Tests link field URL validation.
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 236

Class

LinkFieldTest
Tests link field widgets and formatters.

Namespace

Drupal\Tests\link\Functional

Code

protected function assertInvalidEntries($field_name, array $invalid_entries) {
    foreach ($invalid_entries as $invalid_value => $error_message) {
        $edit = [
            "{$field_name}[0][uri]" => $invalid_value,
        ];
        $this->drupalPostForm('entity_test/add', $edit, t('Save'));
        $this->assertText(t($error_message, [
            '@link_path' => $invalid_value,
        ]));
    }
}

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