Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/path/tests/src/Functional/PathContentModerationTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\path\Functional; | |
4 | |
5 use Drupal\node\Entity\NodeType; | |
6 use Drupal\Tests\BrowserTestBase; | |
7 use Drupal\workflows\Entity\Workflow; | |
8 | |
9 /** | |
10 * Tests path aliases with Content Moderation. | |
11 * | |
12 * @group content_moderation | |
13 * @group path | |
14 */ | |
15 class PathContentModerationTest extends BrowserTestBase { | |
16 | |
17 /** | |
18 * Modules to install. | |
19 * | |
20 * @var array | |
21 */ | |
22 public static $modules = ['node', 'path', 'content_moderation']; | |
23 | |
24 /** | |
25 * {@inheritdoc} | |
26 */ | |
27 protected function setUp() { | |
28 parent::setUp(); | |
29 | |
30 // Created a content type. | |
31 $node_type = NodeType::create(['name' => 'moderated', 'type' => 'moderated']); | |
32 $node_type->save(); | |
33 | |
34 // Set the content type as moderated. | |
35 $workflow = Workflow::load('editorial'); | |
36 $workflow->getTypePlugin()->addEntityTypeAndBundle('node', 'moderated'); | |
37 $workflow->save(); | |
38 | |
39 $this->drupalLogin($this->rootUser); | |
40 } | |
41 | |
42 /** | |
43 * Tests node path aliases on a moderated content type. | |
44 */ | |
45 public function testNodePathAlias() { | |
46 // Create some moderated content with a path alias. | |
47 $this->drupalGet('node/add/moderated'); | |
48 $this->assertSession()->fieldValueEquals('path[0][alias]', ''); | |
49 $this->drupalPostForm(NULL, [ | |
50 'title[0][value]' => 'moderated content', | |
51 'path[0][alias]' => '/moderated-content', | |
52 'moderation_state[0][state]' => 'published', | |
53 ], t('Save')); | |
54 $node = $this->getNodeByTitle('moderated content'); | |
55 | |
56 // Add a pending revision with the same alias. | |
57 $this->drupalGet('node/' . $node->id() . '/edit'); | |
58 $this->assertSession()->fieldValueEquals('path[0][alias]', '/moderated-content'); | |
59 $this->drupalPostForm(NULL, [ | |
60 'title[0][value]' => 'pending revision', | |
61 'path[0][alias]' => '/moderated-content', | |
62 'moderation_state[0][state]' => 'draft', | |
63 ], t('Save')); | |
64 $this->assertSession()->pageTextNotContains('You can only change the URL alias for the published version of this content.'); | |
65 | |
66 // Create some moderated content with no path alias. | |
67 $this->drupalGet('node/add/moderated'); | |
68 $this->assertSession()->fieldValueEquals('path[0][alias]', ''); | |
69 $this->drupalPostForm(NULL, [ | |
70 'title[0][value]' => 'moderated content 2', | |
71 'path[0][alias]' => '', | |
72 'moderation_state[0][state]' => 'published', | |
73 ], t('Save')); | |
74 $node = $this->getNodeByTitle('moderated content 2'); | |
75 | |
76 // Add a pending revision with a new alias. | |
77 $this->drupalGet('node/' . $node->id() . '/edit'); | |
78 $this->assertSession()->fieldValueEquals('path[0][alias]', ''); | |
79 $this->drupalPostForm(NULL, [ | |
80 'title[0][value]' => 'pending revision', | |
81 'path[0][alias]' => '/pending-revision', | |
82 'moderation_state[0][state]' => 'draft', | |
83 ], t('Save')); | |
84 $this->assertSession()->pageTextContains('You can only change the URL alias for the published version of this content.'); | |
85 | |
86 // Create some moderated content with no path alias. | |
87 $this->drupalGet('node/add/moderated'); | |
88 $this->assertSession()->fieldValueEquals('path[0][alias]', ''); | |
89 $this->drupalPostForm(NULL, [ | |
90 'title[0][value]' => 'moderated content 3', | |
91 'path[0][alias]' => '', | |
92 'moderation_state[0][state]' => 'published', | |
93 ], t('Save')); | |
94 $node = $this->getNodeByTitle('moderated content 3'); | |
95 | |
96 // Add a pending revision with no path alias. | |
97 $this->drupalGet('node/' . $node->id() . '/edit'); | |
98 $this->assertSession()->fieldValueEquals('path[0][alias]', ''); | |
99 $this->drupalPostForm(NULL, [ | |
100 'title[0][value]' => 'pending revision', | |
101 'path[0][alias]' => '', | |
102 'moderation_state[0][state]' => 'draft', | |
103 ], t('Save')); | |
104 $this->assertSession()->pageTextNotContains('You can only change the URL alias for the published version of this content.'); | |
105 } | |
106 | |
107 } |