function SandboxManagerBaseTest::testCronDoesNotDeleteWithoutCreateEvent

Same name and namespace in other branches
  1. 11.x core/modules/package_manager/tests/src/Kernel/SandboxManagerBaseTest.php \Drupal\Tests\package_manager\Kernel\SandboxManagerBaseTest::testCronDoesNotDeleteWithoutCreateEvent()

Tests that cron does not delete the sandbox when no create event occurred.

If there's no recorded create event in state (e.g. state was cleared), cron should not attempt to delete the sandbox directory even if it exists.

@legacy-covers \Drupal\package_manager\Hook\CronHook

File

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

Class

SandboxManagerBaseTest
Tests Drupal\package_manager\SandboxManagerBase.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testCronDoesNotDeleteWithoutCreateEvent() : void {
  $stage = $this->createStage();
  $stage->create();
  $dir = $stage->getSandboxDirectory();
  $this->assertDirectoryExists($dir);
  $stage->destroy();
  // Clear the create event timestamp from state.
  $this->container
    ->get('state')
    ->delete(LongLivedSandboxSubscriber::STATE_KEY);
  // Cron should not delete the sandbox directory without a create event.
  $this->container
    ->get('cron')
    ->run();
  $this->assertDirectoryExists($dir);
}

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