Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
329e3c7a
Unverified
Commit
329e3c7a
authored
6 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3042869
by claudiu.cristea, Lendude: Convert UpdateDeleteFileIfStaleTest into a Kernel test
(cherry picked from commit
bdd4ddb9
)
parent
0b3d688d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php
+45
-0
45 additions, 0 deletions
...s/update/tests/src/Kernel/UpdateDeleteFileIfStaleTest.php
with
45 additions
and
0 deletions
core/modules/update/tests/src/
Functiona
l/UpdateDeleteFileIfStaleTest.php
→
core/modules/update/tests/src/
Kerne
l/UpdateDeleteFileIfStaleTest.php
+
45
−
0
View file @
329e3c7a
<?php
namespace
Drupal\Tests\update\Functional
;
namespace
Drupal\Tests\update\Kernel
;
use
Drupal\KernelTests\KernelTestBase
;
/**
* Tests the update_delete_file_if_stale() function.
*
* @group update
*/
class
UpdateDeleteFileIfStaleTest
extends
UpdateTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
[
'update'
];
class
UpdateDeleteFileIfStaleTest
extends
KernelTestBase
{
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
}
protected
static
$modules
=
[
'system'
,
'update'
,
];
/**
* Tests the deletion of stale files.
*/
public
function
testUpdateDeleteFileIfStale
()
{
$file_name
=
\Drupal
::
service
(
'file_system'
)
->
saveData
(
$this
->
randomMachineName
(),
'public://'
);
$file_system
=
$this
->
container
->
get
(
'file_system'
);
$file_name
=
$file_system
->
saveData
(
$this
->
randomMachineName
(),
'public://'
);
$this
->
assertNotNull
(
$file_name
);
// During testing the file change and the stale checking occurs in the same
// request, so the beginning of request will be before the file changes and
// REQUEST_TIME - $filectime is negative. Set the maximum age to a
number
// even smaller than that.
// REQUEST_TIME - $filectime is negative
or zero
. Set the maximum age to a
//
number
even smaller than that.
$this
->
config
(
'system.file'
)
->
set
(
'temporary_maximum_age'
,
-
100000
)
->
save
();
$file_path
=
\Drupal
::
service
(
'
file_system
'
)
->
realpath
(
$file_name
);
$file_path
=
$
file_system
->
realpath
(
$file_name
);
update_delete_file_if_stale
(
$file_path
);
$this
->
assertF
alse
(
is_file
(
$file_path
)
)
;
$this
->
assertF
ileNotExists
(
$file_path
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment