comparison core/modules/node/tests/src/Functional/NodeActionsConfigurationTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests\node\Functional; 3 namespace Drupal\Tests\node\Functional;
4 4
5 use Drupal\Component\Utility\Crypt;
6 use Drupal\Tests\BrowserTestBase; 5 use Drupal\Tests\BrowserTestBase;
7 use Drupal\system\Entity\Action; 6 use Drupal\system\Entity\Action;
8 7
9 /** 8 /**
10 * Tests configuration of actions provided by the Node module. 9 * Tests configuration of actions provided by the Node module.
28 $user = $this->drupalCreateUser(['administer actions']); 27 $user = $this->drupalCreateUser(['administer actions']);
29 $this->drupalLogin($user); 28 $this->drupalLogin($user);
30 29
31 // Make a POST request to admin/config/system/actions. 30 // Make a POST request to admin/config/system/actions.
32 $edit = []; 31 $edit = [];
33 $edit['action'] = Crypt::hashBase64('node_assign_owner_action'); 32 $edit['action'] = 'node_assign_owner_action';
34 $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); 33 $this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
35 $this->assertResponse(200); 34 $this->assertResponse(200);
36 35
37 // Make a POST request to the individual action configuration page. 36 // Make a POST request to the individual action configuration page.
38 $edit = []; 37 $edit = [];
39 $action_label = $this->randomMachineName(); 38 $action_label = $this->randomMachineName();
40 $edit['label'] = $action_label; 39 $edit['label'] = $action_label;
41 $edit['id'] = strtolower($action_label); 40 $edit['id'] = strtolower($action_label);
42 $edit['owner_uid'] = $user->id(); 41 $edit['owner_uid'] = $user->id();
43 $this->drupalPostForm('admin/config/system/actions/add/' . Crypt::hashBase64('node_assign_owner_action'), $edit, t('Save')); 42 $this->drupalPostForm('admin/config/system/actions/add/node_assign_owner_action', $edit, t('Save'));
44 $this->assertResponse(200); 43 $this->assertResponse(200);
44
45 $action_id = $edit['id'];
45 46
46 // Make sure that the new action was saved properly. 47 // Make sure that the new action was saved properly.
47 $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully saved.'); 48 $this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully saved.');
48 $this->assertText($action_label, 'The label of the node_assign_owner_action action appears on the actions administration page after saving.'); 49 $this->assertText($action_label, 'The label of the node_assign_owner_action action appears on the actions administration page after saving.');
49 50
50 // Make another POST request to the action edit page. 51 // Make another POST request to the action edit page.
51 $this->clickLink(t('Configure')); 52 $this->clickLink(t('Configure'));
52 preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches);
53 $aid = $matches[1];
54 $edit = []; 53 $edit = [];
55 $new_action_label = $this->randomMachineName(); 54 $new_action_label = $this->randomMachineName();
56 $edit['label'] = $new_action_label; 55 $edit['label'] = $new_action_label;
57 $edit['owner_uid'] = $user->id(); 56 $edit['owner_uid'] = $user->id();
58 $this->drupalPostForm(NULL, $edit, t('Save')); 57 $this->drupalPostForm(NULL, $edit, t('Save'));
66 // Make sure that deletions work properly. 65 // Make sure that deletions work properly.
67 $this->drupalGet('admin/config/system/actions'); 66 $this->drupalGet('admin/config/system/actions');
68 $this->clickLink(t('Delete')); 67 $this->clickLink(t('Delete'));
69 $this->assertResponse(200); 68 $this->assertResponse(200);
70 $edit = []; 69 $edit = [];
71 $this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete')); 70 $this->drupalPostForm(NULL, $edit, t('Delete'));
72 $this->assertResponse(200); 71 $this->assertResponse(200);
73 72
74 // Make sure that the action was actually deleted. 73 // Make sure that the action was actually deleted.
75 $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.'); 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.');
76 $this->drupalGet('admin/config/system/actions'); 75 $this->drupalGet('admin/config/system/actions');
77 $this->assertResponse(200); 76 $this->assertResponse(200);
78 $this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.'); 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.');
79 78
80 $action = Action::load($aid); 79 $action = Action::load($action_id);
81 $this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.'); 80 $this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.');
82 } 81 }
83 82
84 } 83 }