Newer
Older
Dries Buytaert
committed
<?php
Alex Pott
committed
namespace Drupal\Tests\action\Functional;
use Drupal\system\Entity\Action;
Alex Pott
committed
use Drupal\Tests\BrowserTestBase;
catch
committed
* Tests complex actions configuration by adding, editing, and deleting a
* complex action.
*
* @group action
Alex Pott
committed
class ConfigurationTest extends BrowserTestBase {
Angie Byron
committed
/**
Alex Pott
committed
* Modules to install.
Angie Byron
committed
*
* @var array
*/
public static $modules = ['action'];
Angie Byron
committed
Dries Buytaert
committed
/**
Jennifer Hodgdon
committed
* Tests configuration of advanced actions through administration interface.
Dries Buytaert
committed
*/
public function testActionConfiguration() {
Dries Buytaert
committed
// Create a user with permission to view the actions administration pages.
$user = $this->drupalCreateUser(['administer actions']);
Dries Buytaert
committed
$this->drupalLogin($user);
// Make a POST request to admin/config/system/actions.
$edit = [];
catch
committed
$edit['action'] = 'action_goto_action';
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
$this->assertResponse(200);
Dries Buytaert
committed
// Make a POST request to the individual action configuration page.
$edit = [];
Alex Pott
committed
$action_label = $this->randomMachineName();
$edit['label'] = $action_label;
$edit['id'] = strtolower($action_label);
Dries Buytaert
committed
$edit['url'] = 'admin';
catch
committed
$this->drupalPostForm('admin/config/system/actions/add/action_goto_action', $edit, t('Save'));
$this->assertResponse(200);
Dries Buytaert
committed
Lee Rowlands
committed
$action_id = $edit['id'];
Dries Buytaert
committed
// Make sure that the new complex action was saved properly.
Jennifer Hodgdon
committed
$this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully saved the complex action.");
$this->assertText($action_label, "Make sure the action label appears on the configuration page after we've saved the complex action.");
Dries Buytaert
committed
// Make another POST request to the action edit page.
$this->clickLink(t('Configure'));
Lee Rowlands
committed
$edit = [];
Alex Pott
committed
$new_action_label = $this->randomMachineName();
$edit['label'] = $new_action_label;
Dries Buytaert
committed
$edit['url'] = 'admin';
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
Dries Buytaert
committed
// Make sure that the action updated properly.
Jennifer Hodgdon
committed
$this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully updated the complex action.");
$this->assertNoText($action_label, "Make sure the old action label does NOT appear on the configuration page after we've updated the complex action.");
$this->assertText($new_action_label, "Make sure the action label appears on the configuration page after we've updated the complex action.");
Dries Buytaert
committed
$this->clickLink(t('Configure'));
$element = $this->xpath('//input[@type="text" and @value="admin"]');
$this->assertTrue(!empty($element), 'Make sure the URL appears when re-editing the action.');
Dries Buytaert
committed
// Make sure that deletions work properly.
$this->drupalGet('admin/config/system/actions');
$this->clickLink(t('Delete'));
$this->assertResponse(200);
$edit = [];
Lee Rowlands
committed
$this->drupalPostForm(NULL, $edit, t('Delete'));
$this->assertResponse(200);
Dries Buytaert
committed
// Make sure that the action was actually deleted.
$this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
$this->drupalGet('admin/config/system/actions');
$this->assertResponse(200);
Jennifer Hodgdon
committed
$this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
Lee Rowlands
committed
$action = Action::load($action_id);
$this->assertFalse($action, 'Make sure the action is gone after being deleted.');
Dries Buytaert
committed
}