function PackageManagerKernelTestBase::assertResults

Asserts validation results are returned from a stage life cycle event.

Parameters

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

string|null $event_class: (optional) The class of the event which should return the results. Must be passed if $expected_results is not empty.

Return value

\Drupal\package_manager\StageBase The stage that was used to collect the validation results.

File

core/modules/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php, line 206

Class

PackageManagerKernelTestBase
Base class for kernel tests of Package Manager's functionality.

Namespace

Drupal\Tests\package_manager\Kernel

Code

protected function assertResults(array $expected_results, ?string $event_class = NULL) : StageBase {
    $stage = $this->createStage();
    try {
        $stage->create();
        $stage->require([
            'drupal/core:9.8.1',
        ]);
        $stage->apply();
        $stage->postApply();
        $stage->destroy();
        // If we did not get an exception, ensure we didn't expect any results.
        $this->assertValidationResultsEqual([], $expected_results);
    } catch (StageEventException $e) {
        $this->assertNotEmpty($expected_results);
        $this->assertInstanceOf($event_class, $e->event);
        $this->assertExpectedResultsFromException($expected_results, $e);
    }
    return $stage;
}

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