Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automatic_updates
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
automatic_updates
Merge requests
!78
Issue
#3243422
: Add a kernel test of WritableFileSystemValidator
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3243422
: Add a kernel test of WritableFileSystemValidator
issue/automatic_updates-3243422:3243422-use-vfs
into
8.x-2.x
Overview
1
Commits
7
Pipelines
0
Changes
2
1 unresolved thread
Hide all comments
Merged
Ted Bowman
requested to merge
issue/automatic_updates-3243422:3243422-use-vfs
into
8.x-2.x
3 years ago
Overview
1
Commits
7
Pipelines
0
Changes
2
1 unresolved thread
Hide all comments
Expand
0
0
Merge request reports
Compare
8.x-2.x
version 5
dde0fe37
3 years ago
version 4
1e1cd3f0
3 years ago
version 3
f2e669ec
3 years ago
version 2
e5a80d67
3 years ago
version 1
7615861b
3 years ago
8.x-2.x (base)
and
latest version
latest version
dde0fe37
7 commits,
3 years ago
version 5
dde0fe37
7 commits,
3 years ago
version 4
1e1cd3f0
6 commits,
3 years ago
version 3
f2e669ec
5 commits,
3 years ago
version 2
e5a80d67
4 commits,
3 years ago
version 1
7615861b
2 commits,
3 years ago
2 files
+
122
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
tests/src/Kernel/ReadinessValidation/WritableFileSystemValidatorTest.php
0 → 100644
+
112
−
0
Options
<?php
namespace
Drupal\Tests\automatic_updates\Kernel\ReadinessValidation
;
use
Drupal\automatic_updates
\PathLocator
;
use
Drupal\automatic_updates
\Validation\ValidationResult
;
use
Drupal\automatic_updates
\Validator\WritableFileSystemValidator
;
use
Drupal\Core\DependencyInjection\ContainerBuilder
;
use
Drupal\Tests\automatic_updates
\Kernel\AutomaticUpdatesKernelTestBase
;
use
org\bovigo\vfs\vfsStream
;
/**
* Unit tests the file system permissions validator.
*
* This validator is tested functionally in our build tests, since those give
* us control over the file system permissions.
*
* @see \Drupal\Tests\automatic_updates\Build\CoreUpdateTest::assertReadOnlyFileSystemError()
*
* @covers \Drupal\automatic_updates\Validator\WritableFileSystemValidator
*
* @group automatic_updates
*/
class
WritableFileSystemValidatorTest
extends
AutomaticUpdatesKernelTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'automatic_updates'
,
'package_manager'
,
];
/**
* {@inheritdoc}
*/
protected
function
disableValidators
(
ContainerBuilder
$container
):
void
{
// No need to disable any validators in this test.
}
/**
* Data provider for ::testWritable().
*
* @return array[]
* Sets of arguments to pass to the test method.
*/
public
function
providerWritable
():
array
{
$root_error
=
t
(
'The Drupal directory "vfs://root" is not writable.'
);
$vendor_error
=
t
(
'The vendor directory "vfs://root/vendor" is not writable.'
);
$summary
=
t
(
'The file system is not writable.'
);
$writable_permission
=
0777
;
$non_writable_permission
=
0444
;
return
[
'root and vendor are writable'
=>
[
$writable_permission
,
$writable_permission
,
[],
],
'root writable, vendor not writable'
=>
[
$writable_permission
,
$non_writable_permission
,
[
ValidationResult
::
createError
([
$vendor_error
],
$summary
),
],
],
'root not writable, vendor writable'
=>
[
$non_writable_permission
,
$writable_permission
,
[
ValidationResult
::
createError
([
$root_error
],
$summary
),
],
],
'nothing writable'
=>
[
$non_writable_permission
,
$non_writable_permission
,
[
ValidationResult
::
createError
([
$root_error
,
$vendor_error
],
$summary
),
],
],
];
}
/**
* Tests the file system permissions validator.
*
* @param int $root_permissions
* The file permissions for the root folder.
* @param int $vendor_permissions
* The file permissions for the vendor folder.
* @param array $expected_results
* The expected validation results.
*
* @dataProvider providerWritable
*/
public
function
testWritable
(
int
$root_permissions
,
int
$vendor_permissions
,
array
$expected_results
):
void
{
$files
=
vfsStream
::
setup
(
'root'
,
$root_permissions
);
$files
->
addChild
(
vfsStream
::
newDirectory
(
'vendor'
,
$vendor_permissions
));
$path_locator
=
$this
->
prophesize
(
PathLocator
::
class
);
$path_locator
->
getVendorDirectory
()
->
willReturn
(
vfsStream
::
url
(
'root/vendor'
));
$validator
=
new
WritableFileSystemValidator
(
$path_locator
->
reveal
(),
vfsStream
::
url
(
'root'
),
$this
->
container
->
get
(
'string_translation'
)
);
$this
->
container
->
set
(
'automatic_updates.validator.file_system_permissions'
,
$validator
);
$this
->
assertCheckerResultsFromManager
(
$expected_results
,
TRUE
);
}
}
Loading