public function KeyAdminTest::testKeyListBuilder in Key 8
Tests the key list builder.
File
- tests/
src/ Functional/ KeyAdminTest.php, line 48
Class
- KeyAdminTest
- Tests administration of keys.
Namespace
Drupal\Tests\key\FunctionalCode
public function testKeyListBuilder() {
$this
->drupalLogin($this->adminUser);
$assert_session = $this
->assertSession();
// Go to the Key list page.
$this
->drupalGet('admin/config/system/keys');
$assert_session
->statusCodeEquals(200);
// Verify that the "no keys" message displays.
$assert_session
->responseContains(new FormattableMarkup('No keys are available. <a href=":link">Add a key</a>.', [
':link' => Url::fromRoute('entity.key.add_form')
->toString(),
]));
// Add a key.
$this
->drupalGet('admin/config/system/keys/add');
$edit = [
'id' => 'testing_key',
'label' => 'Testing Key',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// Go to the Key list page.
$this
->drupalGet('admin/config/system/keys');
$assert_session
->statusCodeEquals(200);
// Verify that the "no keys" message does not display.
$assert_session
->pageTextNotContains('No keys are available.');
}