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