NodeHelpTest.php 1.64 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php

/**
 * @file
 * Contains \Drupal\node\Tests\NodeHelpTest.
 */

namespace Drupal\node\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Tests help functionality for nodes.
 *
 * @group node
 */
class NodeHelpTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array.
   */
  public static $modules = array('block', 'node', 'help');

  /**
   * The name of the test node type to create.
   *
   * @var string
   */
  protected $testType;

  /**
   * The test 'node help' text to be checked.
   *
   * @var string
   */
  protected $testText;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    // Create user.
    $admin_user = $this->drupalCreateUser(array(
      'administer content types',
      'administer nodes',
      'bypass node access',
    ));

    $this->drupalLogin($admin_user);
    $this->drupalPlaceBlock('system_help_block');

    $this->testType = 'type';
    $this->testText = t('Help text to find on node forms.');

    // Create content type.
    $this->drupalCreateContentType(array(
      'type' => $this->testType,
      'help' => $this->testText,
    ));
  }

  /**
   * Verifies that help text appears on node add/edit forms.
   */
  public function testNodeShowHelpText() {
    // Check the node add form.
    $this->drupalGet('node/add/' . $this->testType);
    $this->assertResponse(200);
    $this->assertText($this->testText);

    // Create node and check the node edit form.
    $node = $this->drupalCreateNode(array('type' => $this->testType));
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertResponse(200);
    $this->assertText($this->testText);
  }
}