FieldHelpTest.php 1.72 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\field\Functional;
4

5
use Drupal\Tests\BrowserTestBase;
6 7 8

/**
 * Tests help display for the Field module.
9 10
 *
 * @group field
11
 */
12
class FieldHelpTest extends BrowserTestBase {
13 14 15 16

  /**
   * Modules to enable.
   *
17
   * @var array
18
   */
19
  public static $modules = ['field', 'help'];
20 21 22 23 24 25 26 27 28

  // 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
    parent::setUp();

    // Create the admin user.
33
    $this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme']);
34 35 36 37 38 39
  }

  /**
   * 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(['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
}