public function EmbedButtonAdminTest::testEmbedButtonAdmin in Embed 8
Tests the embed_button administration functionality.
File
- tests/
src/ FunctionalJavascript/ EmbedButtonAdminTest.php, line 99
Class
- EmbedButtonAdminTest
- Tests the administrative UI.
Namespace
Drupal\Tests\embed\FunctionalJavascriptCode
public function testEmbedButtonAdmin() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
// Ensure proper access to the Embed settings page.
$this
->drupalGet('admin/config/content/embed');
$assert_session
->pageTextContains('You are not authorized to access this page.');
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/config/content/embed');
// Add embed button.
$this
->clickLink('Add embed button');
$button_label = $this
->randomMachineName();
$button_id = strtolower($button_label);
$page
->fillField('label', $button_label);
$this
->assertNotEmpty($assert_session
->waitForText("Machine name: {$button_id}"));
$edit = [
'type_id' => 'embed_test_default',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// Ensure that the newly created button is listed.
$this
->drupalGet('admin/config/content/embed');
$assert_session
->pageTextContains($button_label);
// Edit embed button.
$this
->drupalGet('admin/config/content/embed/button/manage/' . $button_id);
$new_button_label = $this
->randomMachineName();
$edit = [
'label' => $new_button_label,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
// Ensure that name and label has been changed.
$this
->drupalGet('admin/config/content/embed');
$assert_session
->pageTextContains($new_button_label);
$assert_session
->pageTextNotContains($button_label);
// Delete embed button.
$this
->drupalGet('admin/config/content/embed/button/manage/' . $button_id . '/delete');
$this
->drupalPostForm(NULL, [], 'Delete');
// Ensure that the deleted embed button no longer exists.
$this
->drupalGet('admin/config/content/embed/button/manage/' . $button_id);
$assert_session
->pageTextContains('The requested page could not be found.');
// Ensure that the deleted button is no longer listed.
$this
->drupalGet('admin/config/content/embed');
$assert_session
->pageTextNotContains($button_label);
}