8000 minor #28573 [Filesystem] Skip tests on readable file when run with r… · symfony/symfony@7c87dc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c87dc9

Browse files
minor #28573 [Filesystem] Skip tests on readable file when run with root user (lbassin)
This PR was merged into the 2.8 branch. Discussion ---------- [Filesystem] Skip tests on readable file when run with root user | Q | A | ------------- | --- | Branch? | 2.8 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #28478 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | - <!-- required for new features --> This PR fix tests failures in Filesystem Component when running from a php docker container. By defaut, root user is used to run phpunit. It means permission checking will fail (Root user is always allowed to read files) Linked to #28529 Commits ------- ad500e7 [Filesystem] Skip tests on readable file when run with root user
2 parents afe0812 + ad500e7 commit 7c87dc9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function testCopyUnreadableFileFails()
5050
$this->markTestSkipped('This test cannot run on Windows.');
5151
}
5252

53+
if (!getenv('USER') || 'root' === getenv('USER')) {
54+
$this->markTestSkipped('This test will fail if run under superuser');
55+
}
56+
5357
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
5458
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
5559

@@ -124,6 +128,10 @@ public function testCopyWithOverrideWithReadOnlyTargetFails()
124128
$this->markTestSkipped('This test cannot run on Windows.');
125129
}
126130

131+
if (!getenv('USER') || 'root' === getenv('USER')) {
132+
$this->markTestSkipped('This test will fail if run under superuser');
133+
}
134+
127135
$sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file';
128136
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
129137

src/Symfony/Component/Filesystem/Tests/LockHandlerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function testErrorHandlingInLockIfLockPathBecomesUnwritable()
4949
$this->markTestSkipped('This test cannot run on Windows.');
5050
}
5151

52+
if (!getenv('USER') || 'root' === getenv('USER')) {
53+
$this->markTestSkipped('This test will fail if run under superuser');
54+
}
55+
5256
$lockPath = sys_get_temp_dir().'/'.uniqid('', true);
5357
$e = null;
5458
$wrongMessage = null;

0 commit comments

Comments
 (0)
0