Changeset 37237
- Timestamp:
- 04/18/2016 02:38:49 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/multisite/bootstrap.php
r37236 r37237 87 87 * @ticket 27003 88 88 * @ticket 27927 89 */ 90 function test_get_site_by_path() { 91 $this->assertEquals( self::$site_ids['wordpress.org/'], 92 get_site_by_path( 'wordpress.org', '/notapath/' )->blog_id ); 93 94 $this->assertEquals( self::$site_ids['wordpress.org/'], 95 get_site_by_path( 'www.wordpress.org', '/notapath/' )->blog_id ); 96 97 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 98 get_site_by_path( 'wordpress.org', '/foo/bar/baz/' )->blog_id ); 99 100 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 101 get_site_by_path( 'www.wordpress.org', '/foo/bar/baz/' )->blog_id ); 102 103 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 104 get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 3 )->blog_id ); 105 106 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 107 get_site_by_path( 'www.wordpress.org', '/foo/bar/baz/', 3 )->blog_id ); 108 109 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 110 get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 2 )->blog_id ); 111 112 $this->assertEquals( self::$site_ids['wordpress.org/foo/bar/'], 113 get_site_by_path( 'www.wordpress.org', '/foo/bar/baz/', 2 )->blog_id ); 114 115 $this->assertEquals( self::$site_ids['wordpress.org/foo/'], 116 get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 1 )->blog_id ); 117 118 $this->assertEquals( self::$site_ids['wordpress.org/foo/'], 119 get_site_by_path( 'www.wordpress.org', '/foo/bar/baz/', 1 )->blog_id ); 120 121 $this->assertEquals( self::$site_ids['wordpress.org/'], 122 get_site_by_path( 'wordpress.org', '/', 0 )->blog_id ); 123 124 $this->assertEquals( self::$site_ids['wordpress.org/'], 125 get_site_by_path( 'www.wordpress.org', '/', 0 )->blog_id ); 126 127 $this->assertEquals( self::$site_ids['make.wordpress.org/foo/'], 128 get_site_by_path( 'make.wordpress.org', '/foo/bar/baz/qux/', 4 )->blog_id ); 129 130 $this->assertEquals( self::$site_ids['make.wordpress.org/foo/'], 131 get_site_by_path( 'www.make.wordpress.org', '/foo/bar/baz/qux/', 4 )->blog_id ); 132 133 $this->assertEquals( self::$site_ids['www.w.org/'], 134 get_site_by_path( 'www.w.org', '/', 0 )->blog_id ); 135 136 $this->assertEquals( self::$site_ids['www.w.org/'], 137 get_site_by_path( 'www.w.org', '/notapath/' )->blog_id ); 138 139 $this->assertEquals( self::$site_ids['www.w.org/foo/bar/'], 140 get_site_by_path( 'www.w.org', '/foo/bar/baz/' )->blog_id ); 141 142 $this->assertEquals( self::$site_ids['www.w.org/foo/'], 143 get_site_by_path( 'www.w.org', '/foo/bar/baz/', 1 )->blog_id ); 144 145 // A site installed with www will not be found by the root domain. 146 $this->assertFalse( get_site_by_path( 'w.org', '/' ) ); 147 $this->assertFalse( get_site_by_path( 'w.org', '/notapath/' ) ); 148 $this->assertFalse( get_site_by_path( 'w.org', '/foo/bar/baz/' ) ); 149 $this->assertFalse( get_site_by_path( 'w.org', '/foo/bar/baz/', 1 ) ); 150 151 // A site will not be found by its root domain when an invalid subdomain is requested. 152 $this->assertFalse( get_site_by_path( 'invalid.wordpress.org', '/' ) ); 153 $this->assertFalse( get_site_by_path( 'invalid.wordpress.org', '/foo/bar/' ) ); 89 * @dataProvider data_get_site_by_path 90 * 91 * @param string $expected_key The array key associated with expected data for the test. 92 * @param string $domain The requested domain. 93 * @param string $path The requested path. 94 * @param int $segments Optional. Number of segments to use in `get_site_by_path()`. 95 */ 96 public function test_get_site_by_path( $expected_key, $domain, $path, $segments = null ) { 97 $site = get_site_by_path( $domain, $path, $segments ); 98 99 if ( $expected_key ) { 100 $this->assertEquals( self::$site_ids[ $expected_key ], $site->blog_id ); 101 } else { 102 $this->assertFalse( $site ); 103 } 104 } 105 106 public function data_get_site_by_path() { 107 return array( 108 array( 'wordpress.org/', 'wordpress.org', '/notapath/' ), 109 array( 'wordpress.org/', 'www.wordpress.org', '/notapath/' ), 110 array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/' ), 111 array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/' ), 112 array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 3 ), 113 array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 3 ), 114 array( 'wordpress.org/foo/bar/', 'wordpress.org', '/foo/bar/baz/', 2 ), 115 array( 'wordpress.org/foo/bar/', 'www.wordpress.org', '/foo/bar/baz/', 2 ), 116 array( 'wordpress.org/foo/', 'wordpress.org', '/foo/bar/baz/', 1 ), 117 array( 'wordpress.org/foo/', 'www.wordpress.org', '/foo/bar/baz/', 1 ), 118 array( 'wordpress.org/', 'wordpress.org', '/', 0 ), 119 array( 'wordpress.org/', 'www.wordpress.org', '/', 0 ), 120 array( 'make.wordpress.org/foo/', 'make.wordpress.org', '/foo/bar/baz/quz/', 4 ), 121 array( 'make.wordpress.org/foo/', 'www.make.wordpress.org', '/foo/bar/baz/quz/', 4 ), 122 array( 'www.w.org/', 'www.w.org', '/', 0 ), 123 array( 'www.w.org/', 'www.w.org', '/notapath' ), 124 array( 'www.w.org/foo/bar/', 'www.w.org', '/foo/bar/baz/' ), 125 array( 'www.w.org/foo/', 'www.w.org', '/foo/bar/baz/', 1 ), 126 127 // A site installed with www will not be found by the root domain. 128 array( false, 'w.org', '/' ), 129 array( false, 'w.org', '/notapath/' ), 130 array( false, 'w.org', '/foo/bar/baz/' ), 131 array( false, 'w.org', '/foo/bar/baz/', 1 ), 132 133 // A site will not be found by its root domain when an invalid subdomain is requested. 134 array( false, 'invalid.wordpress.org', '/' ), 135 array( false, 'invalid.wordpress.org', '/foo/bar/' ), 136 ); 154 137 } 155 138
Note: See TracChangeset
for help on using the changeset viewer.