Skip to content

Commit 8303225

Browse files
authored
fix: Avoid to generate a warning caused by skipping the setup (#17)
1 parent dc03299 commit 8303225

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

infection.json.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"@default": true,
1515
"MBString": false,
1616

17+
"global-ignore": [
18+
"Fidry\\FileSystem\\Test\\FileSystemTestCase::tearDown"
19+
],
20+
1721
"FunctionCallRemoval": false,
1822
"MethodCallRemoval": false,
1923
"PublicVisibility": false,

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
bootstrap="vendor/autoload.php"
66
failOnRisky="true"
77
failOnWarning="true"
8+
displayDetailsOnTestsThatTriggerDeprecations="true"
9+
displayDetailsOnTestsThatTriggerNotices="true"
10+
displayDetailsOnTestsThatTriggerWarnings="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
executionOrder="duration"
813
cacheResultFile="dist/.phpunit.result.cache">
914
<php>
1015
<ini name="error_reporting" value="-1"/>

src/Test/FileSystemTestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ protected function setUp(): void
8585

8686
protected function tearDown(): void
8787
{
88-
chdir($this->cwd);
89-
FS::remove($this->tmp);
88+
$wasSetupSkipped = '' === $this->cwd && '' === $this->tmp;
89+
90+
if (!$wasSetupSkipped) {
91+
chdir($this->cwd);
92+
FS::remove($this->tmp);
93+
}
9094
}
9195

9296
/**

tests/Test/FilesystemTestCaseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use Fidry\FileSystem\FS;
4040
use Fidry\FileSystem\Test\FileSystemTestCase;
4141
use PHPUnit\Framework\Attributes\CoversClass;
42+
use PHPUnit\Framework\Attributes\Small;
4243
use Symfony\Component\Finder\Finder;
4344
use function getenv;
4445
use function is_string;
@@ -47,6 +48,7 @@
4748
* @internal
4849
*/
4950
#[CoversClass(FileSystemTestCase::class)]
51+
#[Small]
5052
final class FilesystemTestCaseTest extends FileSystemTestCase
5153
{
5254
public static function getTmpDirNamespace(): string
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
/*
4+
* This code is licensed under the BSD 3-Clause License.
5+
*
6+
* Copyright (c) 2022, Théo FIDRY <[email protected]>
7+
* All rights reserved.
8+
*
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright notice,
16+
* this list of conditions and the following disclaimer in the documentation
17+
* and/or other materials provided with the distribution.
18+
*
19+
* * Neither the name of the copyright holder nor the names of its
20+
* contributors may be used to endorse or promote products derived from
21+
* this software without specific prior written permission.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33+
*/
34+
35+
declare(strict_types=1);
36+
37+
namespace Fidry\FileSystem\Tests\Test;
38+
39+
use Fidry\FileSystem\Test\FileSystemTestCase;
40+
use PHPUnit\Framework\Attributes\CoversNothing;
41+
use PHPUnit\Framework\Attributes\Medium;
42+
use function getenv;
43+
use function is_string;
44+
45+
/**
46+
* @internal
47+
*/
48+
#[CoversNothing]
49+
#[Medium]
50+
final class SkippedFilesystemTest extends FileSystemTestCase
51+
{
52+
public static function getTmpDirNamespace(): string
53+
{
54+
$threadId = getenv('TEST_TOKEN');
55+
56+
if (!is_string($threadId)) {
57+
$threadId = '';
58+
}
59+
60+
return 'FidryFilesystem'.$threadId;
61+
}
62+
63+
protected function setUp(): void
64+
{
65+
self::markTestSkipped();
66+
}
67+
68+
public function test_empty_test(): void
69+
{
70+
$this->addToAssertionCount(1);
71+
}
72+
}

0 commit comments

Comments
 (0)