annotate core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 1fec387a4317
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\node\Functional;
Chris@0 4
Chris@0 5 use Drupal\Tests\BrowserTestBase;
Chris@0 6 use Drupal\system\Entity\Action;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Tests configuration of actions provided by the Node module.
Chris@0 10 *
Chris@0 11 * @group node
Chris@0 12 */
Chris@0 13 class NodeActionsConfigurationTest extends BrowserTestBase {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * Modules to install.
Chris@0 17 *
Chris@0 18 * @var array
Chris@0 19 */
Chris@0 20 public static $modules = ['action', 'node'];
Chris@0 21
Chris@0 22 /**
Chris@0 23 * Tests configuration of the node_assign_owner_action action.
Chris@0 24 */
Chris@0 25 public function testAssignOwnerNodeActionConfiguration() {
Chris@0 26 // Create a user with permission to view the actions administration pages.
Chris@0 27 $user = $this->drupalCreateUser(['administer actions']);
Chris@0 28 $this->drupalLogin($user);
Chris@0 29
Chris@0 30 // Make a POST request to admin/config/system/actions.
Chris@0 31 $edit = [];
Chris@14 32 $edit['action'] = 'node_assign_owner_action';
Chris@0 33 $this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
Chris@0 34 $this->assertResponse(200);
Chris@0 35
Chris@0 36 // Make a POST request to the individual action configuration page.
Chris@0 37 $edit = [];
Chris@0 38 $action_label = $this->randomMachineName();
Chris@0 39 $edit['label'] = $action_label;
Chris@0 40 $edit['id'] = strtolower($action_label);
Chris@0 41 $edit['owner_uid'] = $user->id();
Chris@14 42 $this->drupalPostForm('admin/config/system/actions/add/node_assign_owner_action', $edit, t('Save'));
Chris@0 43 $this->assertResponse(200);
Chris@0 44
Chris@14 45 $action_id = $edit['id'];
Chris@14 46
Chris@0 47 // Make sure that the new action was saved properly.
Chris@0 48 $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully saved.');
Chris@0 49 $this->assertText($action_label, 'The label of the node_assign_owner_action action appears on the actions administration page after saving.');
Chris@0 50
Chris@0 51 // Make another POST request to the action edit page.
Chris@0 52 $this->clickLink(t('Configure'));
Chris@0 53 $edit = [];
Chris@0 54 $new_action_label = $this->randomMachineName();
Chris@0 55 $edit['label'] = $new_action_label;
Chris@0 56 $edit['owner_uid'] = $user->id();
Chris@0 57 $this->drupalPostForm(NULL, $edit, t('Save'));
Chris@0 58 $this->assertResponse(200);
Chris@0 59
Chris@0 60 // Make sure that the action updated properly.
Chris@0 61 $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully updated.');
Chris@0 62 $this->assertNoText($action_label, 'The old label for the node_assign_owner_action action does not appear on the actions administration page after updating.');
Chris@0 63 $this->assertText($new_action_label, 'The new label for the node_assign_owner_action action appears on the actions administration page after updating.');
Chris@0 64
Chris@0 65 // Make sure that deletions work properly.
Chris@0 66 $this->drupalGet('admin/config/system/actions');
Chris@0 67 $this->clickLink(t('Delete'));
Chris@0 68 $this->assertResponse(200);
Chris@0 69 $edit = [];
Chris@14 70 $this->drupalPostForm(NULL, $edit, t('Delete'));
Chris@0 71 $this->assertResponse(200);
Chris@0 72
Chris@0 73 // Make sure that the action was actually deleted.
Chris@0 74 $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.');
Chris@0 75 $this->drupalGet('admin/config/system/actions');
Chris@0 76 $this->assertResponse(200);
Chris@0 77 $this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.');
Chris@0 78
Chris@14 79 $action = Action::load($action_id);
Chris@0 80 $this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.');
Chris@0 81 }
Chris@0 82
Chris@0 83 }