RequirementsTest.php

Same filename in this branch
  1. 11.x core/modules/file/tests/src/Kernel/RequirementsTest.php
  2. 11.x core/modules/mysql/tests/src/Functional/RequirementsTest.php
Same filename and directory in other branches
  1. 9 core/modules/mysql/tests/src/Functional/RequirementsTest.php
  2. 9 core/modules/system/tests/src/Kernel/Module/RequirementsTest.php
  3. 10 core/modules/file/tests/src/Kernel/RequirementsTest.php
  4. 10 core/modules/mysql/tests/src/Functional/RequirementsTest.php
  5. 10 core/modules/system/tests/src/Kernel/Module/RequirementsTest.php

Namespace

Drupal\Tests\system\Kernel\Module

File

core/modules/system/tests/src/Kernel/Module/RequirementsTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\system\Kernel\Module;

use Drupal\Core\Extension\Requirement\RequirementSeverity;
use Drupal\KernelTests\KernelTestBase;

/**
 * Covers hook_requirements and hook_requirements_alter.
 *
 * @group Module
 */
class RequirementsTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'requirements1_test',
    'system',
  ];
  
  /**
   * Tests requirements data altering.
   */
  public function testRequirementsAlter() : void {
    $requirements = $this->container
      ->get('system.manager')
      ->listRequirements();
    // @see requirements1_test_requirements_alter()
    $this->assertEquals('Requirements 1 Test - Changed', $requirements['requirements1_test_alterable']['title']);
    $this->assertEquals(RequirementSeverity::Warning, $requirements['requirements1_test_alterable']['severity']);
    $this->assertArrayNotHasKey('requirements1_test_deletable', $requirements);
  }

}

Classes

Title Deprecated Summary
RequirementsTest Covers hook_requirements and hook_requirements_alter.

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