Changeset 40102 for trunk/tests/phpunit/tests/multisite/bootstrap.php
- Timestamp:
- 02/22/2017 10:41:20 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/bootstrap.php
r38681 r40102 18 18 'make.wordpress.org/' => array( 'domain' => 'make.wordpress.org', 'path' => '/' ), 19 19 'wordpress.org/one/' => array( 'domain' => 'wordpress.org', 'path' => '/one/' ), 20 'wordpress.org/one/b/' => array( 'domain' => 'wordpress.org', 'path' => '/one/b/' ), 20 21 'wordpress.net/' => array( 'domain' => 'wordpress.net', 'path' => '/' ), 21 22 'www.wordpress.net/' => array( 'domain' => 'www.wordpress.net', 'path' => '/' ), … … 81 82 array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A missing path should find the correct network.' ), 82 83 array( 'wordpress.org/one/', 'www.wordpress.org', '/one/', 'Should find the path despite the www.' ), 84 array( 'wordpress.org/one/', 'wordpress.org', '/one/page/', 'A request with two path segments should find the correct network.' ), 85 array( 'wordpress.org/one/b/', 'wordpress.org', '/one/b/', 'A request with two valid path segments should find the correct network.' ), 83 86 array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should not find path because domains do not match.' ), 84 87 array( 'wordpress.net/three/', 'wordpress.net', '/three/', 'A network can have a path.' ), … … 86 89 array( 'wordpress.net/', 'site1.wordpress.net', '/notapath/', 'An invalid subdomain should find the top level network domain.' ), 87 90 array( 'wordpress.net/', 'site1.wordpress.net', '/three/', 'An invalid subdomain and path should find the top level network domain.' ), 88 ); 91 array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ), 92 ); 93 } 94 95 /** 96 * @ticket 37217 97 * @dataProvider data_get_network_by_path_not_using_paths 98 * 99 * @param string $expected_key The array key associated with expected data for the test. 100 * @param string $domain The requested domain. 101 * @param string $path The requested path. 102 * @param string $message The message to pass for failed tests. 103 */ 104 public function test_get_network_by_path_not_using_paths( $expected_key, $domain, $path, $message ) { 105 if ( ! wp_using_ext_object_cache() ) { 106 $this->markTestSkipped( 'Only testable with an external object cache.' ); 107 } 108 109 // Temporarily store original object cache and using paths values. 110 $using_paths_orig = wp_cache_get( 'networks_have_paths', 'site-options' ); 111 112 wp_cache_set( 'networks_have_paths', 0, 'site-options' ); 113 114 $network = get_network_by_path( $domain, $path ); 115 116 // Restore original object cache and using paths values. 117 wp_cache_set( 'networks_have_paths', $using_paths_orig, 'site-options' ); 118 119 $this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message ); 120 } 121 122 public function data_get_network_by_path_not_using_paths() { 123 return array( 124 array( 'wordpress.org/', 'wordpress.org', '/', 'A standard domain and path request should work.' ), 125 array( 'wordpress.net/', 'wordpress.net', '/notapath/', 'A network matching a top level domain should be found regardless of path.' ), 126 array( 'www.wordpress.net/', 'www.wordpress.net', '/notapath/', 'A network matching a domain should be found regardless of path.' ), 127 array( 'wordpress.org/', 'www.wordpress.org', '/one/', 'Should find the network despite the www and regardless of path.' ), 128 array( 'wordpress.org/', 'site1.wordpress.org', '/one/', 'Should find the network with the corresponding top level domain regardless of path.' ), 129 array( 'www.wordpress.net/', 'www.wordpress.net', '/two/', 'A www network can coexist with a non-www network.' ), 130 array( 'make.wordpress.org/', 'make.wordpress.org', '/notapath/', 'A subdomain network should be found regardless of path.' ), 131 array( 'wordpress.net/', 'x.y.wordpress.net', '/', 'An invalid two level subdomain should find the top level network domain.' ), 132 ); 133 } 134 135 /** 136 * Even if a matching network is available, it should not match if the the filtered 137 * value for network path segments is fewer than the number of paths passed. 138 */ 139 public function test_get_network_by_path_with_forced_single_path_segment_returns_single_path_network() { 140 add_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) ); 141 $network = get_network_by_path( 'wordpress.org', '/one/b/' ); 142 remove_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) ); 143 144 $this->assertEquals( self::$network_ids[ 'wordpress.org/one/' ], $network->id ); 145 } 146 147 public function filter_network_path_segments() { 148 return 1; 89 149 } 90 150
Note: See TracChangeset
for help on using the changeset viewer.