function ValidationResultTest::testOverallSeverity

@covers ::getOverallSeverity

File

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

Class

ValidationResultTest
@coversDefaultClass \Drupal\package_manager\ValidationResult[[api-linebreak]] @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 = [
    // phpcs:disable DrupalPractice.Objects.GlobalFunction
ValidationResult::createError([
      t('Boo!'),
    ]),
    ValidationResult::createWarning([
      t('Moo!'),
    ]),
  ];
  $this->assertSame(RequirementSeverity::Error->value, ValidationResult::getOverallSeverity($results));
  // If there are no results, but no errors, the results should be counted as
  // a warning.
  array_shift($results);
  $this->assertSame(RequirementSeverity::Warning->value, ValidationResult::getOverallSeverity($results));
  // If there are just plain no results, we should get
  // RequirementSeverity::OK.
  array_shift($results);
  $this->assertSame(RequirementSeverity::OK->value, ValidationResult::getOverallSeverity($results));
}

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