You are here

public function UsageTest::testTempFileCleanupDefault in Drupal 8

Same name and namespace in other branches
  1. 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 193

Class

UsageTest
Tests file usage functions.

Namespace

Drupal\Tests\file\Kernel

Code

public function testTempFileCleanupDefault() {
  list($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
    ->assertFileNotExists($temp_old
    ->getFileUri());
  $this
    ->assertFileExists($temp_new
    ->getFileUri());
  $this
    ->assertFileExists($perm_old
    ->getFileUri());
  $this
    ->assertFileExists($perm_new
    ->getFileUri());
}