function SandboxManagerBaseTest::testSandboxDirectoryPersistsAndIsReused
Same name and namespace in other branches
- 11.x core/modules/package_manager/tests/src/Kernel/SandboxManagerBaseTest.php \Drupal\Tests\package_manager\Kernel\SandboxManagerBaseTest::testSandboxDirectoryPersistsAndIsReused()
Tests that the sandbox directory persists after destroy and is reused.
The long-lived sandbox directory should survive destroy() and be reused across create/destroy cycles.
@legacy-covers ::getSandboxDirectory @legacy-covers ::destroy @legacy-covers ::create
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ SandboxManagerBaseTest.php, line 516
Class
Namespace
Drupal\Tests\package_manager\KernelCode
public function testSandboxDirectoryPersistsAndIsReused() : void {
$stage = $this->createStage();
$stage->create();
$first_dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($first_dir);
// Place a marker file in the sandbox directory.
file_put_contents($first_dir . '/marker.txt', 'test');
$stage->destroy();
// Directory and its contents should persist after destroy.
$this->assertDirectoryExists($first_dir);
$this->assertFileExists($first_dir . '/marker.txt');
// A second create should succeed with the existing directory and use the
// exact same path.
$stage = $this->createStage();
$stage->create();
$this->assertSame($first_dir, $stage->getSandboxDirectory());
$this->assertDirectoryExists($first_dir);
$stage->destroy();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.