Skip to content

Commit 28ebe35

Browse files
committed
Add unit tests for StringPath to validate various path formats and ensure consistent behavior
1 parent ea29378 commit 28ebe35

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/Unit/String/StringPathTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
use PhpTypedValues\String\StringPath;
77
use PhpTypedValues\Undefined\Alias\Undefined;
88

9+
it('checks valid paths', function (): void {
10+
expect(StringPath::fromString('/etc/passwd')->value())->toBe('/etc/passwd')
11+
->and(StringPath::fromString('etc/passwd')->value())->toBe('etc/passwd')
12+
->and(StringPath::fromString('etc')->value())->toBe('etc')
13+
->and(StringPath::fromString('etc/')->value())->toBe('etc/')
14+
->and(StringPath::fromString('/etc')->value())->toBe('/etc')
15+
->and(StringPath::fromString('etc/passwd/')->value())->toBe('etc/passwd/')
16+
->and(StringPath::fromString('//etc//passwd//')->value())->toBe('//etc//passwd//')
17+
->and(StringPath::fromString('/etc/passwd/')->value())->toBe('/etc/passwd/');
18+
});
19+
920
it('accepts valid path, preserves value/toString and casts via __toString', function (): void {
1021
$p1 = new StringPath('/src/String');
1122
$p2 = new StringPath('src\String\\');

0 commit comments

Comments
 (0)