3 namespace Drupal\Tests\update\Functional;
6 * Tests the update_delete_file_if_stale() function.
10 class UpdateDeleteFileIfStaleTest extends UpdateTestBase {
17 public static $modules = ['update'];
22 protected function setUp() {
27 * Tests the deletion of stale files.
29 public function testUpdateDeleteFileIfStale() {
30 $file_name = file_unmanaged_save_data($this->randomMachineName());
31 $this->assertNotNull($file_name);
33 // During testing the file change and the stale checking occurs in the same
34 // request, so the beginning of request will be before the file changes and
35 // REQUEST_TIME - $filectime is negative. Set the maximum age to a number
36 // even smaller than that.
37 $this->config('system.file')
38 ->set('temporary_maximum_age', -100000)
41 $file_path = drupal_realpath($file_name);
42 update_delete_file_if_stale($file_path);
44 $this->assertFalse(is_file($file_path));