function StageConflictTest::testApplyAndPostApplyInSameRequest
Tests running apply and post-apply in the same request.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ StageConflictTest.php, line 167
Class
- StageConflictTest
- @coversDefaultClass \Drupal\package_manager\SandboxManagerBase[[api-linebreak]] @covers \Drupal\package_manager\PackageManagerUninstallValidator[[api-linebreak]] @group package_manager @group #slow @internal
Namespace
Drupal\Tests\package_manager\KernelCode
public function testApplyAndPostApplyInSameRequest() : void {
$stage = $this->createStage();
$logger = new TestLogger();
$stage->setLogger($logger);
$warning_message = 'Post-apply tasks are running in the same request during which staged changes were applied to the active code base. This can result in unpredictable behavior.';
// Run apply and post-apply in the same request (i.e., the same request
// time), and ensure the warning is logged.
$stage->create();
$stage->require([
'drupal/core:9.8.1',
]);
$stage->apply();
$stage->postApply();
$this->assertTrue($logger->hasRecord($warning_message, LogLevel::WARNING));
$stage->destroy();
$logger->reset();
$stage->create();
$stage->require([
'drupal/core:9.8.2',
]);
$stage->apply();
// Simulate post-apply taking place in another request by simulating a
// request time 30 seconds after apply started.
TestTime::$offset = 30;
$stage->postApply();
$this->assertFalse($logger->hasRecord($warning_message, LogLevel::WARNING));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.