Skip to content

Commit 1f5ac93

Browse files
committed
test(phpunit): Update PHPUnit configuration and add HelpersTest
- Exclude 'src/Support/Rectors/' and 'src/Support/ComposerScripts.php' from coverage - Add new test file 'HelpersTest.php' for support functions - Ensure functions 'escape_argument' and 'str_snake' are tested appropriately This change improves test coverage and ensures relevant functions are validated.
1 parent 9c109ea commit 1f5ac93

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

phpunit.xml.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
<directory suffix=".php">src/</directory>
2222
</include>
2323
<exclude>
24-
<directory>src/Support</directory>
25-
<!--<file>src/Support/helpers.php</file>-->
24+
<directory>src/Support/Rectors/</directory>
25+
<file>src/Support/ComposerScripts.php</file>
2626
</exclude>
2727
</source>
2828
<coverage>
2929
<include>
3030
<directory suffix=".php">src/</directory>
3131
</include>
3232
<exclude>
33-
<directory>src/Support</directory>
34-
<!--<file>src/Support/helpers.php</file>-->
33+
<directory>src/Support/Rectors/</directory>
34+
<file>src/Support/ComposerScripts.php</file>
3535
</exclude>
3636
</coverage>
3737
<extensions>

tests/Support/HelpersTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/** @noinspection AnonymousFunctionStaticInspection */
4+
/** @noinspection NullPointerExceptionInspection */
5+
/** @noinspection PhpPossiblePolymorphicInvocationInspection */
6+
/** @noinspection PhpUnhandledExceptionInspection */
7+
/** @noinspection StaticClosureCanBeUsedInspection */
8+
9+
declare(strict_types=1);
10+
11+
/**
12+
* Copyright (c) 2019-2025 guanguans<ityaozm@gmail.com>
13+
*
14+
* For the full copyright and license information, please view
15+
* the LICENSE file that was distributed with this source code.
16+
*
17+
* @see https://github.com/guanguans/soar-php
18+
*/
19+
20+
use Illuminate\Support\Str;
21+
use function Guanguans\SoarPHP\Support\escape_argument;
22+
use function Guanguans\SoarPHP\Support\str_snake;
23+
24+
it('can escape argument', function (): void {
25+
expect(escape_argument('foo bar baz'))->toBeString();
26+
})->group(__DIR__, __FILE__);
27+
28+
it('can snake string', function (): void {
29+
expect(str_snake(__FILE__))->toBe(Str::of(__FILE__)->snake()->toString());
30+
})->group(__DIR__, __FILE__);

tests/Support/OSTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/** @noinspection AnonymousFunctionStaticInspection */
4+
/** @noinspection NullPointerExceptionInspection */
5+
/** @noinspection PhpPossiblePolymorphicInvocationInspection */
6+
/** @noinspection PhpUnhandledExceptionInspection */
7+
/** @noinspection StaticClosureCanBeUsedInspection */
8+
9+
declare(strict_types=1);
10+
11+
/**
12+
* Copyright (c) 2019-2025 guanguans<ityaozm@gmail.com>
13+
*
14+
* For the full copyright and license information, please view
15+
* the LICENSE file that was distributed with this source code.
16+
*
17+
* @see https://github.com/guanguans/soar-php
18+
*/
19+
20+
use Guanguans\SoarPHP\Support\OS;
21+
22+
it('can check OS', function (): void {
23+
expect(OS::isUnix())->toBeBool()
24+
->and(OS::isWindows())->toBeBool()
25+
->and(OS::isMacOS())->toBeBool();
26+
})->group(__DIR__, __FILE__);
27+
28+
it('can check arch', function (): void {
29+
expect(OS::isArm())->toBeBool()
30+
->and(OS::isPPC())->toBeBool()
31+
->and(OS::isX86())->toBeBool();
32+
})->group(__DIR__, __FILE__);
33+
34+
it('can get arch enum(', function (): void {
35+
expect(OS::getArchEnum())->toBeString();
36+
})->group(__DIR__, __FILE__);

0 commit comments

Comments
 (0)