mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Add unit tests for path_join().
Props karlijnbk. See #55897. git-svn-id: https://develop.svn.wordpress.org/trunk@53457 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b654298687
commit
153a886eaf
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user