comparison core/modules/update/tests/src/Functional/UpdateDeleteFileIfStaleTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\update\Functional;
4
5 /**
6 * Tests the update_delete_file_if_stale() function.
7 *
8 * @group update
9 */
10 class UpdateDeleteFileIfStaleTest extends UpdateTestBase {
11
12 /**
13 * Modules to enable.
14 *
15 * @var array
16 */
17 public static $modules = ['update'];
18
19 /**
20 * {@inheritdoc}
21 */
22 protected function setUp() {
23 parent::setUp();
24 }
25
26 /**
27 * Tests the deletion of stale files.
28 */
29 public function testUpdateDeleteFileIfStale() {
30 $file_name = file_unmanaged_save_data($this->randomMachineName());
31 $this->assertNotNull($file_name);
32
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)
39 ->save();
40
41 $file_path = drupal_realpath($file_name);
42 update_delete_file_if_stale($file_path);
43
44 $this->assertFalse(is_file($file_path));
45 }
46
47 }