Mercurial > hg > isophonics-drupal-site
comparison core/modules/action/tests/src/Functional/ConfigurationTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\action\Functional; | |
4 | |
5 use Drupal\Component\Utility\Crypt; | |
6 use Drupal\system\Entity\Action; | |
7 use Drupal\Tests\BrowserTestBase; | |
8 | |
9 /** | |
10 * Tests complex actions configuration by adding, editing, and deleting a | |
11 * complex action. | |
12 * | |
13 * @group action | |
14 */ | |
15 class ConfigurationTest extends BrowserTestBase { | |
16 | |
17 /** | |
18 * Modules to install. | |
19 * | |
20 * @var array | |
21 */ | |
22 public static $modules = ['action']; | |
23 | |
24 /** | |
25 * Tests configuration of advanced actions through administration interface. | |
26 */ | |
27 public function testActionConfiguration() { | |
28 // Create a user with permission to view the actions administration pages. | |
29 $user = $this->drupalCreateUser(['administer actions']); | |
30 $this->drupalLogin($user); | |
31 | |
32 // Make a POST request to admin/config/system/actions. | |
33 $edit = []; | |
34 $edit['action'] = Crypt::hashBase64('action_goto_action'); | |
35 $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); | |
36 $this->assertResponse(200); | |
37 | |
38 // Make a POST request to the individual action configuration page. | |
39 $edit = []; | |
40 $action_label = $this->randomMachineName(); | |
41 $edit['label'] = $action_label; | |
42 $edit['id'] = strtolower($action_label); | |
43 $edit['url'] = 'admin'; | |
44 $this->drupalPostForm('admin/config/system/actions/add/' . Crypt::hashBase64('action_goto_action'), $edit, t('Save')); | |
45 $this->assertResponse(200); | |
46 | |
47 // Make sure that the new complex action was saved properly. | |
48 $this->assertText(t('The action has been successfully saved.'), "Make sure we get a confirmation that we've successfully saved the complex action."); | |
49 $this->assertText($action_label, "Make sure the action label appears on the configuration page after we've saved the complex action."); | |
50 | |
51 // Make another POST request to the action edit page. | |
52 $this->clickLink(t('Configure')); | |
53 preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches); | |
54 $aid = $matches[1]; | |
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("admin/config/system/actions/configure/$aid/delete", $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($aid); | |
86 $this->assertFalse($action, 'Make sure the action is gone after being deleted.'); | |
87 } | |
88 | |
89 } |