Tests: Use a data provider when testing path slashing in update_blog_details()
.
Trims down 11 tests to 1 clean area of testing and makes for a much saner read. See #32988. git-svn-id: https://develop.svn.wordpress.org/trunk@33254 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e3e828c608
commit
76ef07903d
@ -234,80 +234,35 @@ class Tests_Multisite_Update_Blog_Details extends WP_UnitTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the path for a site is updated with update_blog_details(), the final
|
* When the path for a site is updated with update_blog_details(), the final path
|
||||||
* path should have a leading and trailing slash. When multiple directories
|
* should have a leading and trailing slash.
|
||||||
* are part of the path, only one slash should separate each directory.
|
|
||||||
*
|
*
|
||||||
* @ticket 18117
|
* @dataProvider data_single_directory_path
|
||||||
*/
|
*/
|
||||||
function test_update_blog_details_single_path_no_slashes() {
|
public function test_update_blog_details_single_directory_path( $path, $expected ) {
|
||||||
update_blog_details( 1, array( 'path' => 'my_path' ) );
|
update_blog_details( 1, array( 'path' => $path ) );
|
||||||
$blog = get_blog_details( 1 );
|
$site = get_blog_details( 1 );
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
|
||||||
|
$this->assertEquals( $expected, $site->path );
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_update_blog_details_single_path_double_trailing_slashes() {
|
public function data_single_directory_path() {
|
||||||
update_blog_details( 1, array( 'path' => 'my_path//' ) );
|
return array(
|
||||||
$blog = get_blog_details( 1 );
|
array( 'my_path', '/my_path/' ),
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
array( 'my_path//', '/my_path/' ),
|
||||||
}
|
array( '//my_path', '/my_path/' ),
|
||||||
|
array( 'my_path/', '/my_path/' ),
|
||||||
|
array( '/my_path', '/my_path/' ),
|
||||||
|
array( '/my_path/', '/my_path/' ),
|
||||||
|
|
||||||
function test_update_blog_details_single_path_double_leading_slashes() {
|
array( 'multiple/dirs', '/multiple/dirs/' ),
|
||||||
update_blog_details( 1, array( 'path' => '//my_path' ) );
|
array( '/multiple/dirs', '/multiple/dirs/' ),
|
||||||
$blog = get_blog_details( 1 );
|
array( 'multiple/dirs/', '/multiple/dirs/' ),
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
array( '/multiple/dirs/', '/multiple/dirs/' ),
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_single_path_single_trailing_slash() {
|
// update_blog_details() does not resolve multiple slashes in the middle of a path string.
|
||||||
update_blog_details( 1, array( 'path' => 'my_path/' ) );
|
array( 'multiple///dirs', '/multiple///dirs/' ),
|
||||||
$blog = get_blog_details( 1 );
|
);
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_single_path_single_leading_slashes() {
|
|
||||||
update_blog_details( 1, array( 'path' => '/my_path' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_single_path_both_slashes() {
|
|
||||||
update_blog_details( 1, array( 'path' => '/my_path/' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/my_path/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_multiple_paths_no_slashes() {
|
|
||||||
update_blog_details( 1, array( 'path' => 'multiple/dirs' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/multiple/dirs/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* `update_blog_details()` does not resolve multiple slashes in the
|
|
||||||
* middle of a path string.
|
|
||||||
*/
|
|
||||||
function test_update_blog_details_multiple_paths_middle_slashes() {
|
|
||||||
update_blog_details( 1, array( 'path' => 'multiple///dirs' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/multiple///dirs/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_multiple_paths_leading_slash() {
|
|
||||||
update_blog_details( 1, array( 'path' => '/multiple/dirs' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/multiple/dirs/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_multiple_paths_trailing_slash() {
|
|
||||||
update_blog_details( 1, array( 'path' => 'multiple/dirs/' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/multiple/dirs/', $blog->path );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_update_blog_details_multiple_paths_both_slashes() {
|
|
||||||
update_blog_details( 1, array( 'path' => '/multiple/dirs/' ) );
|
|
||||||
$blog = get_blog_details( 1 );
|
|
||||||
$this->assertEquals( '/multiple/dirs/', $blog->path );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user