From 69761927315a54facc8bf8afca7759d5e95ca6d2 Mon Sep 17 00:00:00 2001 From: Iman Date: Thu, 30 May 2024 17:47:12 +0330 Subject: [PATCH] add test for join_paths (#51621) --- tests/Filesystem/JoinPathsHelperTest.php | 30 ++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/Filesystem/JoinPathsHelperTest.php b/tests/Filesystem/JoinPathsHelperTest.php index 2a4d7cf2e089..6b34efc21bd7 100644 --- a/tests/Filesystem/JoinPathsHelperTest.php +++ b/tests/Filesystem/JoinPathsHelperTest.php @@ -19,8 +19,19 @@ public function testItCanMergePathsForUnix(string $expected, string $given) public static function unixDataProvider() { - yield ['app/Http/Kernel.php', join_paths('app', 'Http', 'Kernel.php')]; - yield ['app/Http/Kernel.php', join_paths('app', '', 'Http', 'Kernel.php')]; + yield ['very/Basic/Functionality.php', join_paths('very', 'Basic', 'Functionality.php')]; + yield ['segments/get/ltrimed/by_directory/separator.php', join_paths('segments', '/get/ltrimed', '/by_directory/separator.php')]; + yield ['only/\\os_separator\\/\\get_ltrimmed.php', join_paths('only', '\\os_separator\\', '\\get_ltrimmed.php')]; + yield ['/base_path//does_not/get_trimmed.php', join_paths('/base_path/', '/does_not', '/get_trimmed.php')]; + yield ['Empty/1/Segments/00/Get_removed.php', join_paths('Empty', '', '0', null, 0, false, [], '1', 'Segments', '00', 'Get_removed.php')]; + yield ['', join_paths(null, null, '')]; + yield ['app/objecty', join_paths('app', new class() + { + public function __toString() + { + return 'objecty'; + } + })]; } #[RequiresOperatingSystem('Windows')] @@ -32,7 +43,18 @@ public function testItCanMergePathsForWindows(string $expected, string $given) public static function windowsDataProvider() { - yield ['app\Http\Kernel.php', join_paths('app', 'Http', 'Kernel.php')]; - yield ['app\Http\Kernel.php', join_paths('app', '', 'Http', 'Kernel.php')]; + yield ['app\Basic\Functionality.php', join_paths('app', 'Basic', 'Functionality.php')]; + yield ['segments\get\ltrimed\by_directory\separator.php', join_paths('segments', '\get\ltrimed', '\by_directory\separator.php')]; + yield ['only\\/os_separator/\\/get_ltrimmed.php', join_paths('only', '/os_separator/', '/get_ltrimmed.php')]; + yield ['\base_path\\\\does_not\get_trimmed.php', join_paths('\\base_path\\', '\does_not', '\get_trimmed.php')]; + yield ['Empty\1\Segments\00\Get_removed.php', join_paths('Empty', '', '0', null, 0, false, [], '1', 'Segments', '00', 'Get_removed.php')]; + yield ['', join_paths(null, null, '')]; + yield ['app\\objecty', join_paths('app', new class() + { + public function __toString() + { + return 'objecty'; + } + })]; } }