class ExperimentalHelpTest

Same name in this branch
  1. 11.x core/modules/help/tests/src/Functional/ExperimentalHelpTest.php \Drupal\Tests\help\Functional\ExperimentalHelpTest
Same name and namespace in other branches
  1. 10 core/modules/help/tests/src/Functional/ExperimentalHelpTest.php \Drupal\Tests\help\Functional\ExperimentalHelpTest
  2. 9 core/modules/help/tests/src/Functional/ExperimentalHelpTest.php \Drupal\Tests\help\Functional\ExperimentalHelpTest
  3. 8.9.x core/modules/help/tests/src/Functional/ExperimentalHelpTest.php \Drupal\Tests\help\Functional\ExperimentalHelpTest
  4. main core/modules/help/tests/src/Functional/ExperimentalHelpTest.php \Drupal\Tests\help\Functional\ExperimentalHelpTest

Verifies help for experimental modules.

Attributes

#[Group('help')] #[RunTestsInSeparateProcesses]

Hierarchy

Expanded class hierarchy of ExperimentalHelpTest

File

core/modules/help/tests/src/Kernel/ExperimentalHelpTest.php, line 17

Namespace

Drupal\Tests\help\Kernel
View source
class ExperimentalHelpTest extends KernelTestBase {
  use HttpKernelUiHelperTrait;
  use UserCreationTrait;
  
  /**
   * Modules to install.
   *
   * The experimental_module_test module implements hook_help() and is in the
   * Core (Experimental) package.
   *
   * @var array
   */
  protected static $modules = [
    'help',
    'experimental_module_test',
    'help_page_test',
    'user',
    'system',
  ];
  
  /**
   * The admin user.
   */
  protected UserInterface $adminUser;
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->installEntitySchema('user');
    $this->adminUser = $this->createUser([
      'access help pages',
    ]);
    $this->setCurrentUser($this->adminUser);
  }
  
  /**
   * Verifies that a warning message is displayed for experimental modules.
   */
  public function testExperimentalHelp() : void {
    $this->drupalGet('admin/help/experimental_module_test');
    $this->assertSession()
      ->statusMessageContains('This module is experimental.', 'warning');
    // Regular modules should not display the message.
    $this->drupalGet('admin/help/help_page_test');
    $this->assertSession()
      ->statusMessageNotContains('This module is experimental.');
    // Ensure the actual help page is displayed to avoid a false positive.
    $this->assertSession()
      ->statusCodeEquals(200);
    $this->assertSession()
      ->pageTextContains('online documentation for the Help Page Test module');
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.