You are here

function UsageTest::testTempFileCleanupDefault in Zircon Profile 8.0

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

Ensure that temporary files are removed by default.

File

core/modules/file/src/Tests/UsageTest.php, line 162
Contains \Drupal\file\Tests\UsageTest.

Class

UsageTest
Tests file usage functions.

Namespace

Drupal\file\Tests

Code

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
    ->assertFalse(file_exists($temp_old
    ->getFileUri()), 'Old temp file was correctly removed.');
  $this
    ->assertTrue(file_exists($temp_new
    ->getFileUri()), 'New temp file was correctly ignored.');
  $this
    ->assertTrue(file_exists($perm_old
    ->getFileUri()), 'Old permanent file was correctly ignored.');
  $this
    ->assertTrue(file_exists($perm_new
    ->getFileUri()), 'New permanent file was correctly ignored.');
}