Skip to content

Commit ca38e9f

Browse files
committed
Removed tests that are touching FS from Path unit tests
1 parent 3d377c0 commit ca38e9f

2 files changed

Lines changed: 10 additions & 105 deletions

File tree

src/lib/filesystem/tests/Flow/Filesystem/Tests/Unit/Path/UnixPathTest.php

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Flow\Filesystem\Tests\Unit\Path;
66

77
use function Flow\Filesystem\DSL\{partition};
8-
use Flow\Filesystem\Exception\{InvalidArgumentException, RuntimeException};
8+
use Flow\Filesystem\Exception\{InvalidArgumentException};
99
use Flow\Filesystem\Path\{Options, UnixPath};
1010
use Flow\Filesystem\Tests\Unit\PathTestCase;
1111

@@ -195,17 +195,6 @@ public function test_fnmatch_with_hidden_files() : void
195195
self::assertTrue($pattern->matches($hidden));
196196
}
197197

198-
public function test_home_path_resolution() : void
199-
{
200-
if (!\is_string($homeEnv = \getenv('HOME'))) {
201-
self::markTestSkipped('HOME environment variable not available');
202-
}
203-
204-
$path = new UnixPath('~/test.txt');
205-
self::assertStringStartsWith($homeEnv, $path->path());
206-
self::assertStringEndsWith('/test.txt', $path->path());
207-
}
208-
209198
public function test_is_equal() : void
210199
{
211200
$path1 = new UnixPath('/path/to/file.txt');
@@ -432,54 +421,6 @@ public function test_randomize_without_extension() : void
432421
self::assertNotEquals($path->path(), $randomized->path());
433422
}
434423

435-
public function test_realpath_home_resolution_error_no_posix() : void
436-
{
437-
if (\function_exists('posix_getpwuid') && \function_exists('posix_getuid')) {
438-
self::markTestSkipped('POSIX functions are available');
439-
}
440-
441-
$originalHome = \getenv('HOME');
442-
\putenv('HOME=');
443-
444-
try {
445-
$this->expectException(RuntimeException::class);
446-
$this->expectExceptionMessage('Resolving homedir is not yet supported at OS');
447-
448-
UnixPath::realpath('~/test.txt');
449-
} finally {
450-
if ($originalHome !== false) {
451-
\putenv('HOME=' . $originalHome);
452-
}
453-
}
454-
}
455-
456-
public function test_realpath_home_resolution_with_posix() : void
457-
{
458-
if (!\function_exists('posix_getpwuid') || !\function_exists('posix_getuid')) {
459-
self::markTestSkipped('POSIX functions not available');
460-
}
461-
462-
$originalHome = \getenv('HOME');
463-
\putenv('HOME=');
464-
465-
try {
466-
$userData = \posix_getpwuid(\posix_getuid());
467-
468-
if (\is_array($userData) && \array_key_exists('dir', $userData) && \is_string($userData['dir'])) {
469-
$path = UnixPath::realpath('~/test.txt');
470-
// Due to implementation details, this might resolve to /test.txt
471-
// when HOME is not set properly
472-
self::assertStringEndsWith('/test.txt', $path->path());
473-
} else {
474-
self::markTestSkipped('Unable to get user directory from POSIX');
475-
}
476-
} finally {
477-
if ($originalHome !== false) {
478-
\putenv('HOME=' . $originalHome);
479-
}
480-
}
481-
}
482-
483424
public function test_realpath_multiple_parent_navigation() : void
484425
{
485426
$path = UnixPath::realpath('/a/b/c/../../d/../e/file.txt');

src/lib/filesystem/tests/Flow/Filesystem/Tests/Unit/Path/WindowsPathTest.php

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Flow\Filesystem\Tests\Unit\Path;
66

77
use function Flow\Filesystem\DSL\{partition};
8-
use Flow\Filesystem\Exception\{InvalidArgumentException, RuntimeException};
8+
use Flow\Filesystem\Exception\{InvalidArgumentException};
99
use Flow\Filesystem\Path\{Options, WindowsPath};
1010
use Flow\Filesystem\Tests\Unit\PathTestCase;
1111

@@ -492,36 +492,6 @@ public function test_randomize_without_extension() : void
492492
self::assertNotEquals($path->path(), $randomized->path());
493493
}
494494

495-
public function test_realpath_home_resolution_error() : void
496-
{
497-
$originalUserProfile = \getenv('USERPROFILE');
498-
$originalHomeDrive = \getenv('HOMEDRIVE');
499-
$originalHomePath = \getenv('HOMEPATH');
500-
501-
\putenv('USERPROFILE=');
502-
\putenv('HOMEDRIVE=');
503-
\putenv('HOMEPATH=');
504-
505-
try {
506-
$this->expectException(RuntimeException::class);
507-
$this->expectExceptionMessage('Cannot resolve home directory on Windows');
508-
509-
WindowsPath::realpath('~/test.txt');
510-
} finally {
511-
if ($originalUserProfile !== false) {
512-
\putenv('USERPROFILE=' . $originalUserProfile);
513-
}
514-
515-
if ($originalHomeDrive !== false) {
516-
\putenv('HOMEDRIVE=' . $originalHomeDrive);
517-
}
518-
519-
if ($originalHomePath !== false) {
520-
\putenv('HOMEPATH=' . $originalHomePath);
521-
}
522-
}
523-
}
524-
525495
public function test_realpath_with_absolute_path() : void
526496
{
527497
$path = WindowsPath::realpath('C:/absolute/path/file.txt');
@@ -535,12 +505,6 @@ public function test_realpath_with_non_file_scheme() : void
535505
self::assertEquals('s3://bucket/key.txt', $path->uri());
536506
}
537507

538-
public function test_realpath_with_unc_path() : void
539-
{
540-
$path = WindowsPath::realpath('\\\\server\\share\\file.txt');
541-
self::assertEquals('/server/share/file.txt', $path->path());
542-
}
543-
544508
public function test_root_directory_name_with_drive() : void
545509
{
546510
$path = new WindowsPath('C:/folder/file.txt');
@@ -571,28 +535,28 @@ public function test_root_partition_edge_case() : void
571535
self::assertEquals('file://group=a/file.txt', $partitioned->uri());
572536
}
573537

574-
public function test_set_extension_with_root_file() : void
538+
public function test_set_extension_edge_case() : void
575539
{
576-
$path = new WindowsPath('/file');
540+
$path = new WindowsPath('file');
577541
$newPath = $path->setExtension('txt');
578542

579543
self::assertEquals('//file.txt', $newPath->path());
580544
}
581545

582-
public function test_set_extension_without_existing_extension() : void
546+
public function test_set_extension_with_root_file() : void
583547
{
584-
$path = new WindowsPath('/path/to/file');
548+
$path = new WindowsPath('/file');
585549
$newPath = $path->setExtension('txt');
586550

587-
self::assertEquals('/path/to/file.txt', $newPath->path());
551+
self::assertEquals('//file.txt', $newPath->path());
588552
}
589553

590-
public function test_set_extension_edge_case() : void
554+
public function test_set_extension_without_existing_extension() : void
591555
{
592-
$path = new WindowsPath('file');
556+
$path = new WindowsPath('/path/to/file');
593557
$newPath = $path->setExtension('txt');
594558

595-
self::assertEquals('//file.txt', $newPath->path());
559+
self::assertEquals('/path/to/file.txt', $newPath->path());
596560
}
597561

598562
public function test_skip_directories() : void

0 commit comments

Comments
 (0)