Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates-3449631
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
automatic_updates-3449631
Commits
35ba7688
Commit
35ba7688
authored
3 years ago
by
Adam G-H
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3258464
by phenaproxima: Remove FileSystemOperationsTest
parent
27bee216
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/FileSystemOperationsTest.php
+0
-148
0 additions, 148 deletions
tests/src/Functional/FileSystemOperationsTest.php
with
0 additions
and
148 deletions
tests/src/Functional/FileSystemOperationsTest.php
deleted
100644 → 0
+
0
−
148
View file @
27bee216
<?php
namespace
Drupal\Tests\automatic_updates\Functional
;
use
Drupal\automatic_updates
\Updater
;
use
Drupal\Core\Site\Settings
;
use
Drupal\package_manager
\PathLocator
;
/**
* Tests handling of files and directories during an update.
*
* @group automatic_updates
*/
class
FileSystemOperationsTest
extends
AutomaticUpdatesFunctionalTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'automatic_updates_test'
];
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* The updater service under test.
*
* @var \Drupal\Tests\automatic_updates\Functional\TestUpdater
*/
private
$updater
;
/**
* The full path of the staging directory.
*
* @var string
*/
protected
$stageDir
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// Create a mocked path locator that uses the fake site fixture as its
// active directory, and has a staging area within the site directory for
// this test.
$drupal_root
=
$this
->
getDrupalRoot
();
/** @var \Drupal\package_manager\PathLocator|\Prophecy\Prophecy\ObjectProphecy $locator */
$locator
=
$this
->
prophesize
(
PathLocator
::
class
);
$locator
->
getActiveDirectory
()
->
willReturn
(
__DIR__
.
'/../../fixtures/fake-site'
);
$this
->
stageDir
=
implode
(
DIRECTORY_SEPARATOR
,
[
$drupal_root
,
$this
->
siteDirectory
,
'stage'
,
]);
$locator
->
getProjectRoot
()
->
willReturn
(
$drupal_root
);
$locator
->
getWebRoot
()
->
willReturn
(
''
);
$this
->
updater
=
new
TestUpdater
(
$locator
->
reveal
(),
$this
->
container
->
get
(
'package_manager.beginner'
),
$this
->
container
->
get
(
'package_manager.stager'
),
$this
->
container
->
get
(
'package_manager.committer'
),
$this
->
container
->
get
(
'file_system'
),
$this
->
container
->
get
(
'event_dispatcher'
),
$this
->
container
->
get
(
'tempstore.shared'
)
);
$this
->
updater
::
$stagingRoot
=
$this
->
stageDir
;
// Use the public and private files directories in the fake site fixture.
$settings
=
Settings
::
getAll
();
$settings
[
'file_public_path'
]
=
'files/public'
;
$settings
[
'file_private_path'
]
=
'files/private'
;
new
Settings
(
$settings
);
// Updater::begin() will trigger update validators, such as
// \Drupal\automatic_updates\Validator\UpdateVersionValidator, that need to
// fetch release metadata. We need to ensure that those HTTP request(s)
// succeed, so set them up to point to our fake release metadata.
$this
->
setReleaseMetadata
(
__DIR__
.
'/../../fixtures/release-history/drupal.9.8.1-security.xml'
);
$this
->
setCoreVersion
(
'9.8.0'
);
$this
->
drupalLogin
(
$this
->
rootUser
);
$this
->
checkForUpdates
();
$this
->
drupalLogout
();
}
/**
* Tests that certain files and directories are not staged.
*
* @covers \Drupal\automatic_updates\Updater::getExclusions
*/
public
function
testExclusions
():
void
{
$stage_id
=
$this
->
updater
->
begin
([
'drupal'
=>
'9.8.1'
]);
$this
->
assertFileDoesNotExist
(
"
$this->stageDir
/
$stage_id
/sites/default/settings.php"
);
$this
->
assertFileDoesNotExist
(
"
$this->stageDir
/
$stage_id
/sites/default/settings.local.php"
);
$this
->
assertFileDoesNotExist
(
"
$this->stageDir
/
$stage_id
/sites/default/services.yml"
);
// A file in sites/default, that isn't one of the site-specific settings
// files, should be staged.
$this
->
assertFileExists
(
"
$this->stageDir
/
$stage_id
/sites/default/staged.txt"
);
$this
->
assertDirectoryDoesNotExist
(
"
$this->stageDir
/
$stage_id
/sites/simpletest"
);
$this
->
assertDirectoryDoesNotExist
(
"
$this->stageDir
/
$stage_id
/files/public"
);
$this
->
assertDirectoryDoesNotExist
(
"
$this->stageDir
/
$stage_id
/files/private"
);
// A file that's in the general files directory, but not in the public or
// private directories, should be staged.
$this
->
assertFileExists
(
"
$this->stageDir
/
$stage_id
/files/staged.txt"
);
}
/**
* Tests that the staging directory is properly cleaned up.
*
* @covers \Drupal\automatic_updates\Cleaner
*/
public
function
testClean
():
void
{
$stage_id
=
$this
->
updater
->
begin
([
'drupal'
=>
'9.8.1'
]);
// Make the staged site directory read-only, so we can test that it will be
// made writable on clean-up.
$this
->
assertTrue
(
chmod
(
"
$this->stageDir
/
$stage_id
/sites/default"
,
0400
));
$this
->
assertIsNotWritable
(
"
$this->stageDir
/
$stage_id
/sites/default/staged.txt"
);
// If the site directory is not writable, this will throw an exception.
$this
->
updater
->
destroy
();
$this
->
assertDirectoryDoesNotExist
(
$this
->
stageDir
);
}
}
/**
* A test-only version of the updater.
*/
class
TestUpdater
extends
Updater
{
/**
* The directory where staging areas will be created.
*
* @var string
*/
public
static
$stagingRoot
;
/**
* {@inheritdoc}
*/
protected
static
function
getStagingRoot
():
string
{
return
static
::
$stagingRoot
?:
parent
::
getStagingRoot
();
}
}
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