NodeHelpTest.php 1.6 KB

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