Same filename and directory in other branches
- 8.9.x core/modules/action/tests/src/Functional/ConfigurationTest.php
- 9 core/modules/action/tests/src/Functional/ConfigurationTest.php
Namespace
Drupal\Tests\action\Functional
File
core/modules/action/tests/src/Functional/ConfigurationTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\action\Functional;
use Drupal\system\Entity\Action;
use Drupal\Tests\BrowserTestBase;
class ConfigurationTest extends BrowserTestBase {
protected static $modules = [
'action',
];
protected $defaultTheme = 'stark';
public function testActionConfiguration() {
$user = $this
->drupalCreateUser([
'administer actions',
]);
$this
->drupalLogin($user);
$edit = [];
$edit['action'] = 'action_goto_action';
$this
->drupalGet('admin/config/system/actions');
$this
->submitForm($edit, 'Create');
$this
->assertSession()
->statusCodeEquals(200);
$edit = [];
$action_label = $this
->randomMachineName();
$edit['label'] = $action_label;
$edit['id'] = strtolower($action_label);
$edit['url'] = 'admin';
$this
->drupalGet('admin/config/system/actions/add/action_goto_action');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$action_id = $edit['id'];
$this
->assertSession()
->pageTextContains('The action has been successfully saved.');
$this
->assertSession()
->pageTextContains($action_label);
$this
->clickLink('Configure');
$edit = [];
$new_action_label = $this
->randomMachineName();
$edit['label'] = $new_action_label;
$edit['url'] = 'admin';
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains('The action has been successfully saved.');
$this
->assertSession()
->pageTextNotContains($action_label);
$this
->assertSession()
->pageTextContains($new_action_label);
$this
->clickLink('Configure');
$this
->assertSession()
->fieldValueEquals('url', 'admin');
$this
->drupalGet('admin/config/system/actions');
$this
->clickLink('Delete');
$this
->assertSession()
->statusCodeEquals(200);
$edit = [];
$this
->submitForm($edit, 'Delete');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains("The action {$new_action_label} has been deleted.");
$this
->drupalGet('admin/config/system/actions');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextNotContains($new_action_label);
$action = Action::load($action_id);
$this
->assertNull($action, 'Make sure the action is gone after being deleted.');
}
}
Classes