minor #38560 [CI] Silence errors when remove file/dir on test tearDown() (Nyholm)

This PR was merged into the 3.4 branch.

Discussion
----------

[CI] Silence errors when remove file/dir on test tearDown()

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  |
| Deprecations? |
| Tickets       |
| License       | MIT
| Doc PR        |

Requested in #38556

Commits
-------

efef41faa1 [CI] Silence errors when remove file/dir on test tearDown()
This commit is contained in:
Fabien Potencier 2020-10-14 09:59:59 +02:00
commit 9b2dcac5d3
13 changed files with 18 additions and 22 deletions

View File

@ -120,7 +120,7 @@ class LintCommandTest extends TestCase
{ {
foreach ($this->files as $file) { foreach ($this->files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); @unlink($file);
} }
} }
} }

View File

@ -174,9 +174,9 @@ EOF;
{ {
foreach ($this->files as $file) { foreach ($this->files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); @unlink($file);
} }
} }
rmdir(sys_get_temp_dir().'/yml-lint-test'); @rmdir(sys_get_temp_dir().'/yml-lint-test');
} }
} }

View File

@ -30,7 +30,7 @@ class ConfigCacheTest extends TestCase
foreach ($files as $file) { foreach ($files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); @unlink($file);
} }
} }
} }

View File

@ -30,7 +30,7 @@ class FileExistenceResourceTest extends TestCase
protected function tearDown() protected function tearDown()
{ {
if (file_exists($this->file)) { if (file_exists($this->file)) {
unlink($this->file); @unlink($this->file);
} }
} }

View File

@ -30,11 +30,9 @@ class FileResourceTest extends TestCase
protected function tearDown() protected function tearDown()
{ {
if (!file_exists($this->file)) { if (file_exists($this->file)) {
return; @unlink($this->file);
} }
unlink($this->file);
} }
public function testGetResource() public function testGetResource()

View File

@ -31,7 +31,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
foreach ($files as $file) { foreach ($files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); @unlink($file);
} }
} }
} }

View File

@ -103,11 +103,9 @@ class AutowireServiceResourceTest extends TestCase
protected function tearDown() protected function tearDown()
{ {
if (!file_exists($this->file)) { if (file_exists($this->file)) {
return; @unlink($this->file);
} }
unlink($this->file);
} }
private function getStaleFileTime() private function getStaleFileTime()

View File

@ -165,9 +165,9 @@ class FileBagTest extends TestCase
protected function tearDown() protected function tearDown()
{ {
foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) { foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) {
unlink($file); @unlink($file);
} }
rmdir(sys_get_temp_dir().'/form_test'); @rmdir(sys_get_temp_dir().'/form_test');
} }
} }

View File

@ -43,7 +43,7 @@ class MockFileSessionStorageTest extends TestCase
{ {
array_map('unlink', glob($this->sessionDir.'/*')); array_map('unlink', glob($this->sessionDir.'/*'));
if (is_dir($this->sessionDir)) { if (is_dir($this->sessionDir)) {
rmdir($this->sessionDir); @rmdir($this->sessionDir);
} }
$this->sessionDir = null; $this->sessionDir = null;
$this->storage = null; $this->storage = null;

View File

@ -47,7 +47,7 @@ class NativeSessionStorageTest extends TestCase
session_write_close(); session_write_close();
array_map('unlink', glob($this->savePath.'/*')); array_map('unlink', glob($this->savePath.'/*'));
if (is_dir($this->savePath)) { if (is_dir($this->savePath)) {
rmdir($this->savePath); @rmdir($this->savePath);
} }
$this->savePath = null; $this->savePath = null;

View File

@ -43,7 +43,7 @@ class PhpBridgeSessionStorageTest extends TestCase
session_write_close(); session_write_close();
array_map('unlink', glob($this->savePath.'/*')); array_map('unlink', glob($this->savePath.'/*'));
if (is_dir($this->savePath)) { if (is_dir($this->savePath)) {
rmdir($this->savePath); @rmdir($this->savePath);
} }
$this->savePath = null; $this->savePath = null;

View File

@ -45,7 +45,7 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
} }
if (file_exists($this->path)) { if (file_exists($this->path)) {
unlink($this->path); @unlink($this->path);
} }
$this->path = null; $this->path = null;

View File

@ -123,11 +123,11 @@ YAML;
{ {
foreach ($this->files as $file) { foreach ($this->files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
unlink($file); @unlink($file);
} }
} }
rmdir(sys_get_temp_dir().'/framework-yml-lint-test'); @rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
} }
} }