55namespace Flow \Filesystem \Tests \Unit \Path ;
66
77use function Flow \Filesystem \DSL \{partition };
8- use Flow \Filesystem \Exception \{InvalidArgumentException , RuntimeException };
8+ use Flow \Filesystem \Exception \{InvalidArgumentException };
99use Flow \Filesystem \Path \{Options , WindowsPath };
1010use 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