function ValidationTestTrait::assertValidationResultsEqual

Asserts two validation result sets are equal.

This assertion is sensitive to the order of results. For example, ['a', 'b'] is not equal to ['b', 'a'].

Parameters

\Drupal\package_manager\ValidationResult[] $expected_results: The expected validation results.

\Drupal\package_manager\ValidationResult[] $actual_results: The actual validation results.

\Drupal\package_manager\PathLocator|null $path_locator: (optional) The path locator (when this trait is used in unit tests).

string|null $stage_dir: (optional) The stage directory.

10 calls to ValidationTestTrait::assertValidationResultsEqual()
ComposerMinimumStabilityValidatorTest::testPreRequireEvent in core/modules/package_manager/tests/src/Kernel/ComposerMinimumStabilityValidatorTest.php
Tests error if requested version is less stable than the minimum: stable.
ComposerPatchesValidatorTest::testErrorDuringPreApply in core/modules/package_manager/tests/src/Kernel/ComposerPatchesValidatorTest.php
Tests the patcher's presence and configuration are validated on pre-apply.
DirectWriteTest::testSiteNotSandboxedIfDirectWriteGloballyEnabled in core/modules/package_manager/tests/src/Kernel/DirectWriteTest.php
Tests direct-write mode when globally enabled.
DuplicateInfoFileValidatorTest::testDuplicateInfoFilesInStage in core/modules/package_manager/tests/src/Kernel/DuplicateInfoFileValidatorTest.php
Tests that duplicate info.yml in stage raise an error.
PackageManagerKernelTestBase::assertExpectedResultsFromException in core/modules/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php
Asserts that a StageEventException has a particular set of results.

... See full list

File

core/modules/package_manager/tests/src/Traits/ValidationTestTrait.php, line 36

Class

ValidationTestTrait
Contains helpful methods for testing stage validators.

Namespace

Drupal\Tests\package_manager\Traits

Code

protected function assertValidationResultsEqual(array $expected_results, array $actual_results, ?PathLocator $path_locator = NULL, ?string $stage_dir = NULL) : void {
  if ($path_locator) {
    assert(is_a(get_called_class(), UnitTestCase::class, TRUE));
  }
  $expected_results = array_map(function (array $result) use ($path_locator, $stage_dir) : array {
    $result['messages'] = $this->resolvePlaceholdersInArrayValuesWithRealPaths($result['messages'], $path_locator, $stage_dir);
    return $result;
  }, $this->getValidationResultsAsArray($expected_results));
  $actual_results = $this->getValidationResultsAsArray($actual_results);
  self::assertSame($expected_results, $actual_results);
}

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