function SandboxManagerBaseTest::testTimeouts

Tests that Composer Stager is invoked with a long timeout.

File

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

Class

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

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testTimeouts() : void {
    $stage = $this->createStage();
    $stage->create(420);
    $stage->require([
        'ext-json:*',
    ]);
    $stage->apply();
    $timeouts = [
        // The beginner was given an explicit timeout.
BeginnerInterface::class => 420,
        // The stager should be called with a timeout of 300 seconds, which is
        // longer than Composer Stager's default timeout of 120 seconds.
StagerInterface::class => 300,
        // The committer should have been called with an even longer timeout,
        // since it's the most failure-sensitive operation.
CommitterInterface::class => 600,
    ];
    foreach ($timeouts as $service_id => $expected_timeout) {
        $invocations = $this->container
            ->get($service_id)
            ->getInvocationArguments();
        // The services should have been called with the expected timeouts.
        $expected_count = 1;
        if ($service_id === StagerInterface::class) {
            // Stage::require() calls Stager::stage() twice, once to change the
            // version constraints in composer.json, and again to actually update
            // the installed dependencies.
            $expected_count = 2;
        }
        $this->assertCount($expected_count, $invocations);
        $this->assertSame($expected_timeout, end($invocations[0]));
    }
}

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