From b36363bb69b4a2c89433ff0385ca8f7b01c7c1de Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Tue, 28 Mar 2017 01:24:44 +0000 Subject: [PATCH] Tests: Clarify zero path segment tests for `get_network_by_path()`. The set of assertions in this data provider intend to test a 0 path segment configuration rather than the use of paths. Fixes #37217. git-svn-id: https://develop.svn.wordpress.org/trunk@40342 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/multisite/bootstrap.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/tests/multisite/bootstrap.php b/tests/phpunit/tests/multisite/bootstrap.php index 6b9c9aee49..b1989a37b0 100644 --- a/tests/phpunit/tests/multisite/bootstrap.php +++ b/tests/phpunit/tests/multisite/bootstrap.php @@ -94,32 +94,24 @@ class Tests_Multisite_Bootstrap extends WP_UnitTestCase { /** * @ticket 37217 - * @dataProvider data_get_network_by_path_not_using_paths + * @dataProvider data_get_network_by_path_with_zero_path_segments * * @param string $expected_key The array key associated with expected data for the test. * @param string $domain The requested domain. * @param string $path The requested path. * @param string $message The message to pass for failed tests. */ - public function test_get_network_by_path_not_using_paths( $expected_key, $domain, $path, $message ) { - if ( ! wp_using_ext_object_cache() ) { - $this->markTestSkipped( 'Only testable with an external object cache.' ); - } - - // Temporarily store original object cache and using paths values. - $using_paths_orig = wp_cache_get( 'networks_have_paths', 'site-options' ); - - wp_cache_set( 'networks_have_paths', 0, 'site-options' ); + public function test_get_network_by_path_with_zero_path_segments( $expected_key, $domain, $path, $message ) { + add_filter( 'network_by_path_segments_count', '__return_zero' ); $network = get_network_by_path( $domain, $path ); - // Restore original object cache and using paths values. - wp_cache_set( 'networks_have_paths', $using_paths_orig, 'site-options' ); + remove_filter( 'network_by_path_segments_count', '__return_zero' ); $this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message ); } - public function data_get_network_by_path_not_using_paths() { + public function data_get_network_by_path_with_zero_path_segments() { return array( array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ), array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A network matching a top level domain should be found regardless of path.' ),