function ValidationResultTest::testOverallSeverity

@covers ::getOverallSeverity

File

core/modules/package_manager/tests/src/Unit/ValidationResultTest.php, line 33

Class

ValidationResultTest
@coversDefaultClass \Drupal\package_manager\ValidationResult @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Unit

Code

public function testOverallSeverity() : void {
    // An error and a warning should be counted as an error.
    $results = [
        ValidationResult::createError([
            t('Boo!'),
        ]),
        ValidationResult::createWarning([
            t('Moo!'),
        ]),
    ];
    $this->assertSame(SystemManager::REQUIREMENT_ERROR, ValidationResult::getOverallSeverity($results));
    // If there are no results, but no errors, the results should be counted as
    // a warning.
    array_shift($results);
    $this->assertSame(SystemManager::REQUIREMENT_WARNING, ValidationResult::getOverallSeverity($results));
    // If there are just plain no results, we should get REQUIREMENT_OK.
    array_shift($results);
    $this->assertSame(SystemManager::REQUIREMENT_OK, ValidationResult::getOverallSeverity($results));
}

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