Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Tests\action\Functional;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\system\Entity\Action;
|
Chris@0
|
6 use Drupal\Tests\BrowserTestBase;
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Tests complex actions configuration by adding, editing, and deleting a
|
Chris@0
|
10 * complex action.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @group action
|
Chris@0
|
13 */
|
Chris@0
|
14 class ConfigurationTest extends BrowserTestBase {
|
Chris@0
|
15
|
Chris@0
|
16 /**
|
Chris@0
|
17 * Modules to install.
|
Chris@0
|
18 *
|
Chris@0
|
19 * @var array
|
Chris@0
|
20 */
|
Chris@0
|
21 public static $modules = ['action'];
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Tests configuration of advanced actions through administration interface.
|
Chris@0
|
25 */
|
Chris@0
|
26 public function testActionConfiguration() {
|
Chris@0
|
27 // Create a user with permission to view the actions administration pages.
|
Chris@0
|
28 $user = $this->drupalCreateUser(['administer actions']);
|
Chris@0
|
29 $this->drupalLogin($user);
|
Chris@0
|
30
|
Chris@0
|
31 // Make a POST request to admin/config/system/actions.
|
Chris@0
|
32 $edit = [];
|
Chris@14
|
33 $edit['action'] = 'action_goto_action';
|
Chris@0
|
34 $this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
|
Chris@0
|
35 $this->assertResponse(200);
|
Chris@0
|
36
|
Chris@0
|
37 // Make a POST request to the individual action configuration page.
|
Chris@0
|
38 $edit = [];
|
Chris@0
|
39 $action_label = $this->randomMachineName();
|
Chris@0
|
40 $edit['label'] = $action_label;
|
Chris@0
|
41 $edit['id'] = strtolower($action_label);
|
Chris@0
|
42 $edit['url'] = 'admin';
|
Chris@14
|
43 $this->drupalPostForm('admin/config/system/actions/add/action_goto_action', $edit, t('Save'));
|
Chris@0
|
44 $this->assertResponse(200);
|
Chris@0
|
45
|
Chris@14
|
46 $action_id = $edit['id'];
|
Chris@14
|
47
|
Chris@0
|
48 // Make sure that the new complex action was saved properly.
|
Chris@0
|
49 $this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully saved the complex action.");
|
Chris@0
|
50 $this->assertText($action_label, "Make sure the action label appears on the configuration page after we've saved the complex action.");
|
Chris@0
|
51
|
Chris@0
|
52 // Make another POST request to the action edit page.
|
Chris@0
|
53 $this->clickLink(t('Configure'));
|
Chris@14
|
54
|
Chris@0
|
55 $edit = [];
|
Chris@0
|
56 $new_action_label = $this->randomMachineName();
|
Chris@0
|
57 $edit['label'] = $new_action_label;
|
Chris@0
|
58 $edit['url'] = 'admin';
|
Chris@0
|
59 $this->drupalPostForm(NULL, $edit, t('Save'));
|
Chris@0
|
60 $this->assertResponse(200);
|
Chris@0
|
61
|
Chris@0
|
62 // Make sure that the action updated properly.
|
Chris@0
|
63 $this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully updated the complex action.");
|
Chris@0
|
64 $this->assertNoText($action_label, "Make sure the old action label does NOT appear on the configuration page after we've updated the complex action.");
|
Chris@0
|
65 $this->assertText($new_action_label, "Make sure the action label appears on the configuration page after we've updated the complex action.");
|
Chris@0
|
66
|
Chris@0
|
67 $this->clickLink(t('Configure'));
|
Chris@0
|
68 $element = $this->xpath('//input[@type="text" and @value="admin"]');
|
Chris@0
|
69 $this->assertTrue(!empty($element), 'Make sure the URL appears when re-editing the action.');
|
Chris@0
|
70
|
Chris@0
|
71 // Make sure that deletions work properly.
|
Chris@0
|
72 $this->drupalGet('admin/config/system/actions');
|
Chris@0
|
73 $this->clickLink(t('Delete'));
|
Chris@0
|
74 $this->assertResponse(200);
|
Chris@0
|
75 $edit = [];
|
Chris@14
|
76 $this->drupalPostForm(NULL, $edit, t('Delete'));
|
Chris@0
|
77 $this->assertResponse(200);
|
Chris@0
|
78
|
Chris@0
|
79 // Make sure that the action was actually deleted.
|
Chris@0
|
80 $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
|
Chris@0
|
81 $this->drupalGet('admin/config/system/actions');
|
Chris@0
|
82 $this->assertResponse(200);
|
Chris@0
|
83 $this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
|
Chris@0
|
84
|
Chris@14
|
85 $action = Action::load($action_id);
|
Chris@0
|
86 $this->assertFalse($action, 'Make sure the action is gone after being deleted.');
|
Chris@0
|
87 }
|
Chris@0
|
88
|
Chris@0
|
89 }
|