Version 1
[yaffs-website] / web / core / modules / node / tests / src / Functional / NodeHelpTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests help functionality for nodes.
9  *
10  * @group node
11  */
12 class NodeHelpTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array.
18    */
19   public static $modules = ['block', 'node', 'help'];
20
21   /**
22    * The name of the test node type to create.
23    *
24    * @var string
25    */
26   protected $testType;
27
28   /**
29    * The test 'node help' text to be checked.
30    *
31    * @var string
32    */
33   protected $testText;
34
35   /**
36    * {@inheritdoc}
37    */
38   protected function setUp() {
39     parent::setUp();
40
41     // Create user.
42     $admin_user = $this->drupalCreateUser([
43       'administer content types',
44       'administer nodes',
45       'bypass node access',
46     ]);
47
48     $this->drupalLogin($admin_user);
49     $this->drupalPlaceBlock('help_block');
50
51     $this->testType = 'type';
52     $this->testText = t('Help text to find on node forms.');
53
54     // Create content type.
55     $this->drupalCreateContentType([
56       'type' => $this->testType,
57       'help' => $this->testText,
58     ]);
59   }
60
61   /**
62    * Verifies that help text appears on node add/edit forms.
63    */
64   public function testNodeShowHelpText() {
65     // Check the node add form.
66     $this->drupalGet('node/add/' . $this->testType);
67     $this->assertResponse(200);
68     $this->assertText($this->testText);
69
70     // Create node and check the node edit form.
71     $node = $this->drupalCreateNode(['type' => $this->testType]);
72     $this->drupalGet('node/' . $node->id() . '/edit');
73     $this->assertResponse(200);
74     $this->assertText($this->testText);
75   }
76
77 }