function UsageTest::testTempFileCustomCleanup

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/UsageTest.php \Drupal\Tests\file\Kernel\UsageTest::testTempFileCustomCleanup()
  2. 8.9.x core/modules/file/tests/src/Kernel/UsageTest.php \Drupal\Tests\file\Kernel\UsageTest::testTempFileCustomCleanup()
  3. 11.x core/modules/file/tests/src/Kernel/UsageTest.php \Drupal\Tests\file\Kernel\UsageTest::testTempFileCustomCleanup()

Ensure that temporary files are kept as configured.

File

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

Class

UsageTest
Tests file usage functions.

Namespace

Drupal\Tests\file\Kernel

Code

public function testTempFileCustomCleanup() : void {
    [
        $temp_old,
        $temp_new,
        $perm_old,
        $perm_new,
    ] = $this->createTempFiles();
    // Set the max age to older than default.
    $this->config('system.file')
        ->set('temporary_maximum_age', 21600 + 2)
        ->save();
    // Run cron and then ensure that more files were deleted.
    $this->container
        ->get('cron')
        ->run();
    $this->assertFileExists($temp_old->getFileUri());
    $this->assertFileExists($temp_new->getFileUri());
    $this->assertFileExists($perm_old->getFileUri());
    $this->assertFileExists($perm_new->getFileUri());
}

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