function SandboxManagerBaseTest::testCollectPathsToExclude

Tests that paths to exclude are collected before create and apply.

File

core/modules/package_manager/tests/src/Kernel/SandboxManagerBaseTest.php, line 386

Class

SandboxManagerBaseTest
@coversDefaultClass \Drupal\package_manager\SandboxManagerBase @group package_manager @group #slow @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testCollectPathsToExclude() : void {
    $this->addEventTestListener(function (CollectPathsToExcludeEvent $event) : void {
        $event->add('exclude/me');
    }, CollectPathsToExcludeEvent::class);
    // On pre-create and pre-apply, ensure that the excluded path is known to
    // the event.
    $asserted = FALSE;
    $assert_excluded = function (object $event) use (&$asserted) : void {
        $this->assertContains('exclude/me', $event->excludedPaths
            ->getAll());
        // Use this to confirm that this listener was actually called.
        $asserted = TRUE;
    };
    $this->addEventTestListener($assert_excluded, PreCreateEvent::class);
    $this->addEventTestListener($assert_excluded);
    $stage = $this->createStage();
    $stage->create();
    $this->assertTrue($asserted);
    $asserted = FALSE;
    $stage->require([
        'ext-json:*',
    ]);
    $stage->apply();
    $this->assertTrue($asserted);
}

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