You are here

public function KeyInputTest::testLongKey in Key 8

Tests the a long key input.

File

tests/src/Functional/KeyInputTest.php, line 47

Class

KeyInputTest
Tests input of keys.

Namespace

Drupal\Tests\key\Functional

Code

public function testLongKey() {
  $this
    ->drupalLogin($this->adminUser);
  $assert_session = $this
    ->assertSession();

  // Add a key with a 4000 characters.
  $this
    ->drupalGet('admin/config/system/keys/add');
  $edit = [
    'id' => 'testing_key',
    'label' => 'Testing Key',
    'key_type' => 'authentication',
    'key_input_settings[key_value]' => str_pad('', 4000, 'z'),
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains(sprintf('The key %s has been added.', $edit['label']));

  // Go to the Key page.
  $this
    ->drupalGet('admin/config/system/keys/manage/testing_key');
  $assert_session
    ->statusCodeEquals(200);
}