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