function UpdateRequirementsTest::testUpdateRequirements

Tests hook_update_requirements().

File

core/tests/Drupal/KernelTests/Core/Updater/UpdateRequirementsTest.php, line 22

Class

UpdateRequirementsTest
Tests hook_update_requirements() and hook_update_requirements_alter().

Namespace

Drupal\KernelTests\Core\Updater

Code

public function testUpdateRequirements() : void {
    require_once 'core/includes/update.inc';
    \Drupal::service('module_installer')->install([
        'module_update_requirements',
    ]);
    $testRequirements = [
        'title' => $this->t('UpdateError'),
        'value' => $this->t('None'),
        'description' => $this->t('Update Error.'),
        'severity' => REQUIREMENT_ERROR,
    ];
    $requirements = update_check_requirements()['test.update.error'];
    $this->assertEquals($testRequirements, $requirements);
    $testAlterRequirements = [
        'title' => $this->t('UpdateWarning'),
        'value' => $this->t('None'),
        'description' => $this->t('Update Warning.'),
        'severity' => REQUIREMENT_WARNING,
    ];
    $alterRequirements = update_check_requirements()['test.update.error.alter'];
    $this->assertEquals($testAlterRequirements, $alterRequirements);
}

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