Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / diff / src / Tests / DiffViewModeTest.php
1 <?php
2
3 namespace Drupal\diff\Tests;
4 use Drupal\Tests\diff\Functional\CoreVersionUiTestTrait;
5
6 /**
7  * Tests field visibility when using a custom view mode.
8  *
9  * @group diff
10  */
11 class DiffViewModeTest extends DiffTestBase {
12
13   use CoreVersionUiTestTrait;
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['field_ui'];
21
22   /**
23    * Tests field visibility using a cutom view mode.
24    */
25   public function testViewMode() {
26     $this->drupalLogin($this->rootUser);
27
28     // Create a node.
29     $node = $this->drupalCreateNode([
30       'type' => 'article',
31       'title' => 'Sample node',
32       'body' => [
33         'value' => 'Foo',
34       ],
35     ]);
36
37     // Edit the article and change the email.
38     $edit = array(
39       'body[0][value]' => 'Fighters',
40       'revision' => TRUE,
41     );
42     $this->drupalPostNodeForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
43
44     // Set the Body field to hidden in the diff view mode.
45     $edit = [
46       'fields[body][region]' => 'hidden',
47     ];
48     $this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save'));
49     $edit = [
50       'fields[body][region]' => 'hidden',
51     ];
52     $this->drupalPostForm('admin/structure/types/manage/article/display/teaser', $edit, t('Save'));
53
54     // Check the difference between the last two revisions.
55     $this->drupalGet('node/' . $node->id() . '/revisions');
56     $this->drupalPostForm(NULL, [], t('Compare selected revisions'));
57     $this->assertNoText('Body');
58     $this->assertNoText('Foo');
59     $this->assertNoText('Fighters');
60   }
61
62 }