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. 8.9.x core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertInvalidEntries()
  3. 10 core/modules/link/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\link\Functional\LinkFieldTest::assertInvalidEntries()

Asserts that invalid URLs cannot be submitted.

@internal

Parameters

string $field_name: The field name.

array $invalid_entries: An array of invalid URL entries.

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

Class

LinkFieldTest
Tests link field widgets and formatters.

Namespace

Drupal\Tests\link\Functional

Code

protected function assertInvalidEntries(string $field_name, array $invalid_entries) : void {
    foreach ($invalid_entries as $invalid_value => $error_message) {
        $edit = [
            "{$field_name}[0][uri]" => $invalid_value,
        ];
        $this->drupalGet('entity_test/add');
        $this->submitForm($edit, 'Save');
        $this->assertSession()
            ->responseContains(strtr($error_message, [
            '@link_path' => $invalid_value,
        ]));
    }
}

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