Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\update\Kernel; | |
4 | |
5 use Drupal\KernelTests\KernelTestBase; | |
6 | |
7 /** | |
8 * Tests the update_delete_file_if_stale() function. | |
9 * | |
10 * @group update | |
11 */ | |
12 class UpdateDeleteFileIfStaleTest extends KernelTestBase { | |
13 | |
14 /** | |
15 * {@inheritdoc} | |
16 */ | |
17 protected static $modules = [ | |
18 'system', | |
19 'update', | |
20 ]; | |
21 | |
22 /** | |
23 * Tests the deletion of stale files. | |
24 */ | |
25 public function testUpdateDeleteFileIfStale() { | |
26 $file_system = $this->container->get('file_system'); | |
27 | |
28 $file_name = $file_system->saveData($this->randomMachineName(), 'public://'); | |
29 $this->assertNotNull($file_name); | |
30 | |
31 // During testing the file change and the stale checking occurs in the same | |
32 // request, so the beginning of request will be before the file changes and | |
33 // REQUEST_TIME - $filectime is negative or zero. Set the maximum age to a | |
34 // number even smaller than that. | |
35 $this->config('system.file') | |
36 ->set('temporary_maximum_age', -100000) | |
37 ->save(); | |
38 | |
39 $file_path = $file_system->realpath($file_name); | |
40 update_delete_file_if_stale($file_path); | |
41 | |
42 $this->assertFileNotExists($file_path); | |
43 } | |
44 | |
45 } |