You are here

protected function LinkFieldTest::assertInvalidEntries in Drupal 8

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

1 call to LinkFieldTest::assertInvalidEntries()
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,
    ]));
  }
}