diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index da7daca8bb..10d240b35b 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -129,6 +129,58 @@ class Tests_Functions extends WP_UnitTestCase { } } + /** + * Tests path_join(). + * + * @ticket 55897 + * @dataProvider path_join_data_provider + */ + public function test_path_join( $base, $path, $expected ) { + $this->assertSame( $expected, path_join( $base, $path ) ); + } + + /** + * Data provider for test_path_join(). + * + * @return string[][] + */ + public function path_join_data_provider() { + return array( + // Absolute path. + 'absolute path should return path' => array( + 'base' => 'base', + 'path' => '/path', + 'expected' => '/path', + ), + // Non-absolute paths. + 'join base and path' => array( + 'base' => 'base', + 'path' => 'path', + 'expected' => 'base/path', + ), + 'strip trailing slashes in base' => array( + 'base' => 'base///', + 'path' => 'path', + 'expected' => 'base/path', + ), + 'empty path' => array( + 'base' => 'base', + 'path' => '', + 'expected' => 'base/', + ), + 'empty base' => array( + 'base' => '', + 'path' => 'path', + 'expected' => '/path', + ), + 'empty path and base' => array( + 'base' => '', + 'path' => '', + 'expected' => '/', + ), + ); + } + /** * @ticket 33265 * @ticket 35996