FieldHelpTest.php 1.72 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

namespace Drupal\field\Tests;

use Drupal\simpletest\WebTestBase;

/**
 * Tests help display for the Field module.
9 10
 *
 * @group field
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
 */
class FieldHelpTest extends WebTestBase {

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

  // Tests field help implementation without optional core modules enabled.
  protected $profile = 'minimal';

  /**
   * The admin user that will be created.
   */
  protected $adminUser;

29
  protected function setUp() {
30 31 32 33 34 35 36 37 38 39
    parent::setUp();

    // Create the admin user.
    $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme'));
  }

  /**
   * Test the Field module's help page.
   */
  public function testFieldHelp() {
40
    // Log in the admin user.
41 42 43 44 45
    $this->drupalLogin($this->adminUser);

    // Visit the Help page and make sure no warnings or notices are thrown.
    $this->drupalGet('admin/help/field');

46
    // Enable the Options, Email and Field API Test modules.
47
    \Drupal::service('module_installer')->install(array('options', 'field_test'));
48
    $this->resetAll();
49
    \Drupal::service('plugin.manager.field.widget')->clearCachedDefinitions();
50
    \Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
51 52 53

    $this->drupalGet('admin/help/field');
    $this->assertLink('Options', 0, 'Options module is listed on the Field help page.');
54 55
    $this->assertText('Field API Test', 'Modules with field types that do not implement hook_help are listed.');
    $this->assertNoLink('Field API Test', 'Modules with field types that do not implement hook_help are not linked.');
56 57
    $this->assertNoLink('Link', 'Modules that have not been installed, are not listed.');
  }
58

59
}