You are here

public function UsageTest::testTempFileCleanupDefault in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/UsageTest.php \Drupal\Tests\file\Kernel\UsageTest::testTempFileCleanupDefault()
  2. 9 core/modules/file/tests/src/Kernel/UsageTest.php \Drupal\Tests\file\Kernel\UsageTest::testTempFileCleanupDefault()

Ensure that temporary files are removed by default.

File

core/modules/file/tests/src/Kernel/UsageTest.php, line 197

Class

UsageTest
Tests file usage functions.

Namespace

Drupal\Tests\file\Kernel

Code

public function testTempFileCleanupDefault() {
  [
    $temp_old,
    $temp_new,
    $perm_old,
    $perm_new,
  ] = $this
    ->createTempFiles();

  // Run cron and then ensure that only the old, temp file was deleted.
  $this->container
    ->get('cron')
    ->run();
  $this
    ->assertFileDoesNotExist($temp_old
    ->getFileUri());
  $this
    ->assertFileExists($temp_new
    ->getFileUri());
  $this
    ->assertFileExists($perm_old
    ->getFileUri());
  $this
    ->assertFileExists($perm_new
    ->getFileUri());
}