Skip to content

Commit

Permalink
add test for join_paths
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed May 29, 2024
1 parent 97238d2 commit cb31e3d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions tests/Filesystem/JoinPathsHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ 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')]
Expand All @@ -32,7 +42,17 @@ 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';
}
})];
}
}

0 comments on commit cb31e3d

Please sign in to comment.