Tests: Use a data provider to test `get_network_by_path()`
See #36566, #34941. git-svn-id: https://develop.svn.wordpress.org/trunk@37236 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a3eb12ddbb
commit
48ba391b9b
|
@ -62,33 +62,25 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 27003
|
* @ticket 27003
|
||||||
|
* @dataProvider data_get_network_by_path
|
||||||
*/
|
*/
|
||||||
function test_get_network_by_path() {
|
function test_get_network_by_path( $expected_key, $request_domain, $request_path, $message ) {
|
||||||
$this->assertEquals( self::$network_ids['www.wordpress.net/'],
|
$network = get_network_by_path( $request_domain, $request_path );
|
||||||
get_network_by_path( 'www.wordpress.net', '/notapath/' )->id );
|
$this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message );
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertEquals( self::$network_ids['www.wordpress.net/two/'],
|
public function data_get_network_by_path() {
|
||||||
get_network_by_path( 'www.wordpress.net', '/two/' )->id );
|
return array(
|
||||||
|
array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ),
|
||||||
// This should find /one/ despite the www.
|
array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A missing path on a top level domain should find the correct network.' ),
|
||||||
$this->assertEquals( self::$network_ids['wordpress.org/one/'],
|
array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A missing path should find the correct network.' ),
|
||||||
get_network_by_path( 'www.wordpress.org', '/one/' )->id );
|
array( 'wordpress.org/one/', 'www.wordpress.org', '/one/', 'Should find the path despite the www.' ),
|
||||||
|
array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should not find path because domains do not match.' ),
|
||||||
// This should not find /one/ because the domains don't match.
|
array( 'wordpress.net/three/', 'wordpress.net', '/three/', 'A network can have a path.' ),
|
||||||
$this->assertEquals( self::$network_ids['wordpress.org/'],
|
array( 'www.wordpress.net/two/', 'www.wordpress.net', '/two/', 'A www network with a path can coexist with a non-www network.' ),
|
||||||
get_network_by_path( 'site1.wordpress.org', '/one/' )->id );
|
array( 'wordpress.net/', 'site1.wordpress.net', '/notapath/', 'An invalid subdomain should find the top level network domain.' ),
|
||||||
|
array( 'wordpress.net/', 'site1.wordpress.net', '/three/', 'An invalid subdomain and path should find the top level network domain.' ),
|
||||||
$this->assertEquals( self::$network_ids['wordpress.net/three/'],
|
);
|
||||||
get_network_by_path( 'wordpress.net', '/three/' )->id );
|
|
||||||
|
|
||||||
$this->assertEquals( self::$network_ids['wordpress.net/'],
|
|
||||||
get_network_by_path( 'wordpress.net', '/notapath/' )->id );
|
|
||||||
|
|
||||||
$this->assertEquals( self::$network_ids['wordpress.net/'],
|
|
||||||
get_network_by_path( 'site1.wordpress.net', '/notapath/' )->id );
|
|
||||||
|
|
||||||
$this->assertEquals( self::$network_ids['wordpress.net/'],
|
|
||||||
get_network_by_path( 'site1.wordpress.net', '/three/' )->id );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue