NoHelpTest.php 1.37 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\help\Functional;
4

5
use Drupal\Tests\BrowserTestBase;
6 7

/**
8 9 10
 * Verify no help is displayed for modules not providing any help.
 *
 * @group help
11
 */
12
class NoHelpTest extends BrowserTestBase {
13 14 15 16 17 18

  /**
   * Modules to enable.
   *
   * Use one of the test modules that do not implement hook_help().
   *
19
   * @var array
20
   */
21
  public static $modules = ['help', 'menu_test'];
22

23 24 25
  /**
   * The user who will be created.
   */
26
  protected $adminUser;
27

28
  protected function setUp() {
29
    parent::setUp();
30
    $this->adminUser = $this->drupalCreateUser(['access administration pages']);
31 32 33 34 35
  }

  /**
   * Ensures modules not implementing help do not appear on admin/help.
   */
36 37
  public function testMainPageNoHelp() {
    $this->drupalLogin($this->adminUser);
38 39

    $this->drupalGet('admin/help');
40
    $this->assertResponse(200);
41
    $this->assertText('Module overviews are provided by modules');
42 43 44 45 46
    $this->assertFalse(\Drupal::moduleHandler()->implementsHook('menu_test', 'help'), 'The menu_test module does not implement hook_help');
    $this->assertNoText(\Drupal::moduleHandler()->getName('menu_test'), 'Making sure the test module menu_test does not display a help link on admin/help.');

    $this->drupalGet('admin/help/menu_test');
    $this->assertResponse(404, 'Getting a module overview help page for a module that does not implement hook_help() results in a 404.');
47
  }
48

49
}