Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\node\Functional; | |
4 | |
5 use Drupal\node\Entity\NodeType; | |
6 | |
7 /** | |
8 * Tests the revision tab display. | |
9 * | |
10 * This test is similar to NodeRevisionsUITest except that it uses a user with | |
11 * the bypass node access permission to make sure that the revision access | |
12 * check adds correct cacheability metadata. | |
13 * | |
14 * @group node | |
15 */ | |
16 class NodeRevisionsUiBypassAccessTest extends NodeTestBase { | |
17 | |
18 /** | |
19 * User with bypass node access permission. | |
20 * | |
21 * @var \Drupal\user\Entity\User | |
22 */ | |
23 protected $editor; | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 public static $modules = ['block']; | |
29 | |
30 /** | |
31 * {@inheritdoc} | |
32 */ | |
33 protected function setUp() { | |
34 parent::setUp(); | |
35 | |
36 // Create a user. | |
37 $this->editor = $this->drupalCreateUser([ | |
38 'administer nodes', | |
39 'edit any page content', | |
40 'view page revisions', | |
41 'bypass node access', | |
42 'access user profiles', | |
43 ]); | |
44 } | |
45 | |
46 /** | |
47 * Checks that the Revision tab is displayed correctly. | |
48 */ | |
49 public function testDisplayRevisionTab() { | |
50 $this->drupalPlaceBlock('local_tasks_block'); | |
51 | |
52 $this->drupalLogin($this->editor); | |
53 $node_storage = $this->container->get('entity.manager')->getStorage('node'); | |
54 | |
55 // Set page revision setting 'create new revision'. This will mean new | |
56 // revisions are created by default when the node is edited. | |
57 $type = NodeType::load('page'); | |
58 $type->setNewRevision(TRUE); | |
59 $type->save(); | |
60 | |
61 // Create the node. | |
62 $node = $this->drupalCreateNode(); | |
63 | |
64 // Verify the checkbox is checked on the node edit form. | |
65 $this->drupalGet('node/' . $node->id() . '/edit'); | |
66 $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); | |
67 | |
68 // Uncheck the create new revision checkbox and save the node. | |
69 $edit = ['revision' => FALSE]; | |
70 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); | |
71 | |
72 $this->assertUrl($node->toUrl()); | |
73 $this->assertNoLink(t('Revisions')); | |
74 | |
75 // Verify the checkbox is checked on the node edit form. | |
76 $this->drupalGet('node/' . $node->id() . '/edit'); | |
77 $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); | |
78 | |
79 // Submit the form without changing the checkbox. | |
80 $edit = []; | |
81 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); | |
82 | |
83 $this->assertUrl($node->toUrl()); | |
84 $this->assertLink(t('Revisions')); | |
85 } | |
86 | |
87 } |