Changeset 42343 for trunk/tests/phpunit/tests/rewrite.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/rewrite.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rewrite.php
r41786 r42343 53 53 $redirect = 'index.php?test_var1=$matches[1]&test_var2=1'; 54 54 55 $wp_rewrite->add_rule( $pattern, array( 56 'test_var1' => '$matches[1]', 57 'test_var2' => '1' 58 ) ); 55 $wp_rewrite->add_rule( 56 $pattern, array( 57 'test_var1' => '$matches[1]', 58 'test_var2' => '1', 59 ) 60 ); 59 61 60 62 $wp_rewrite->flush_rules(); … … 93 95 94 96 function test_url_to_postid_set_url_scheme_https_to_http() { 95 $post_id = self::factory()->post->create();97 $post_id = self::factory()->post->create(); 96 98 $permalink = get_permalink( $post_id ); 97 99 $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); 98 100 99 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) );101 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 100 102 $permalink = get_permalink( $post_id ); 101 103 $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); … … 125 127 $_SERVER['HTTPS'] = 'on'; 126 128 127 $network_home = home_url();129 $network_home = home_url(); 128 130 $this->blog_id_35531 = self::factory()->blog->create(); 129 131 … … 182 184 function test_url_to_postid_hierarchical() { 183 185 184 $parent_id = self::factory()->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) ); 185 $child_id = self::factory()->post->create( array( 'post_title' => 'Child', 'post_type' => 'page', 'post_parent' => $parent_id ) ); 186 $parent_id = self::factory()->post->create( 187 array( 188 'post_title' => 'Parent', 189 'post_type' => 'page', 190 ) 191 ); 192 $child_id = self::factory()->post->create( 193 array( 194 'post_title' => 'Child', 195 'post_type' => 'page', 196 'post_parent' => $parent_id, 197 ) 198 ); 186 199 187 200 $this->assertEquals( $parent_id, url_to_postid( get_permalink( $parent_id ) ) ); … … 191 204 function test_url_to_postid_hierarchical_with_matching_leaves() { 192 205 193 $parent_id = self::factory()->post->create( array( 194 'post_name' => 'parent', 195 'post_type' => 'page', 196 ) ); 197 $child_id_1 = self::factory()->post->create( array( 198 'post_name' => 'child1', 199 'post_type' => 'page', 200 'post_parent' => $parent_id, 201 ) ); 202 $child_id_2 = self::factory()->post->create( array( 203 'post_name' => 'child2', 204 'post_type' => 'page', 205 'post_parent' => $parent_id, 206 ) ); 207 $grandchild_id_1 = self::factory()->post->create( array( 208 'post_name' => 'grandchild', 209 'post_type' => 'page', 210 'post_parent' => $child_id_1, 211 ) ); 212 $grandchild_id_2 = self::factory()->post->create( array( 213 'post_name' => 'grandchild', 214 'post_type' => 'page', 215 'post_parent' => $child_id_2, 216 ) ); 206 $parent_id = self::factory()->post->create( 207 array( 208 'post_name' => 'parent', 209 'post_type' => 'page', 210 ) 211 ); 212 $child_id_1 = self::factory()->post->create( 213 array( 214 'post_name' => 'child1', 215 'post_type' => 'page', 216 'post_parent' => $parent_id, 217 ) 218 ); 219 $child_id_2 = self::factory()->post->create( 220 array( 221 'post_name' => 'child2', 222 'post_type' => 'page', 223 'post_parent' => $parent_id, 224 ) 225 ); 226 $grandchild_id_1 = self::factory()->post->create( 227 array( 228 'post_name' => 'grandchild', 229 'post_type' => 'page', 230 'post_parent' => $child_id_1, 231 ) 232 ); 233 $grandchild_id_2 = self::factory()->post->create( 234 array( 235 'post_name' => 'grandchild', 236 'post_type' => 'page', 237 'post_parent' => $child_id_2, 238 ) 239 ); 217 240 218 241 $this->assertEquals( home_url( 'parent/child1/grandchild/' ), get_permalink( $grandchild_id_1 ) ); … … 226 249 update_option( 'home', home_url( '/example/' ) ); 227 250 228 $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'examp' ) ); 251 $id = self::factory()->post->create( 252 array( 253 'post_title' => 'Hi', 254 'post_type' => 'page', 255 'post_name' => 'examp', 256 ) 257 ); 229 258 $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); 230 $this->assertEquals( $id, url_to_postid( site_url( '/example/examp' ) ) );259 $this->assertEquals( $id, url_to_postid( site_url( '/example/examp' ) ) ); 231 260 $this->assertEquals( $id, url_to_postid( '/example/examp/' ) ); 232 261 $this->assertEquals( $id, url_to_postid( '/example/examp' ) ); … … 250 279 251 280 $this->go_to( $home_url . 'page' ); 252 $this->assertEquals( array( 'page' => '', 'pagename' => 'page' ), $GLOBALS['wp']->query_vars ); 281 $this->assertEquals( 282 array( 283 'page' => '', 284 'pagename' => 'page', 285 ), $GLOBALS['wp']->query_vars 286 ); 253 287 } 254 288 … … 257 291 */ 258 292 function test_parse_request_home_path_with_regex_character() { 259 $home_url = home_url( '/ma.ch/' );293 $home_url = home_url( '/ma.ch/' ); 260 294 $not_a_home_url = home_url( '/match/' ); 261 295 update_option( 'home', $home_url ); … … 265 299 266 300 $this->go_to( $home_url . 'page' ); 267 $this->assertEquals( array( 'page' => '', 'pagename' => 'page' ), $GLOBALS['wp']->query_vars ); 301 $this->assertEquals( 302 array( 303 'page' => '', 304 'pagename' => 'page', 305 ), $GLOBALS['wp']->query_vars 306 ); 268 307 269 308 $this->go_to( $not_a_home_url . 'page' ); 270 $this->assertNotEquals( array( 'page' => '', 'pagename' => 'page' ), $GLOBALS['wp']->query_vars ); 271 $this->assertEquals( array( 'page' => '', 'pagename' => 'match/page' ), $GLOBALS['wp']->query_vars ); 309 $this->assertNotEquals( 310 array( 311 'page' => '', 312 'pagename' => 'page', 313 ), $GLOBALS['wp']->query_vars 314 ); 315 $this->assertEquals( 316 array( 317 'page' => '', 318 'pagename' => 'match/page', 319 ), $GLOBALS['wp']->query_vars 320 ); 272 321 } 273 322 … … 288 337 289 338 function test_url_to_postid_dupe_path() { 290 update_option( 'home', home_url('/example/') ); 291 292 $id = self::factory()->post->create( array( 'post_title' => 'Hi', 'post_type' => 'page', 'post_name' => 'example' ) ); 339 update_option( 'home', home_url( '/example/' ) ); 340 341 $id = self::factory()->post->create( 342 array( 343 'post_title' => 'Hi', 344 'post_type' => 'page', 345 'post_name' => 'example', 346 ) 347 ); 293 348 294 349 $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); … … 304 359 update_option( 'home', home_url( '/example' ) ); 305 360 306 self::factory()->post->create( array( 'post_title' => 'Collision', 'post_type' => 'page', 'post_name' => 'collision' ) ); 361 self::factory()->post->create( 362 array( 363 'post_title' => 'Collision', 364 'post_type' => 'page', 365 'post_name' => 'collision', 366 ) 367 ); 307 368 308 369 // This url should NOT return a post ID … … 313 374 /** 314 375 * Reveals bug introduced in WP 3.0 376 * 315 377 * @group ms-required 316 378 */ … … 319 381 switch_to_blog( $blog_id ); 320 382 321 self::factory()->post->create( array( 'post_title' => 'Collision ', 'post_type' => 'page' ) ); 383 self::factory()->post->create( 384 array( 385 'post_title' => 'Collision ', 386 'post_type' => 'page', 387 ) 388 ); 322 389 323 390 // This url should NOT return a post ID … … 334 401 $this->set_permalink_structure( '/%postname%/' ); 335 402 336 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); 403 $page_id = self::factory()->post->create( 404 array( 405 'post_type' => 'page', 406 'post_status' => 'trash', 407 ) 408 ); 337 409 $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); 338 410 … … 366 438 $this->set_permalink_structure( '/%postname%/' ); 367 439 368 $post_id = self::factory()->post->create( array( 'post_name' => 'foo-bar-baz' ) );440 $post_id = self::factory()->post->create( array( 'post_name' => 'foo-bar-baz' ) ); 369 441 $permalink = get_permalink( $post_id ); 370 $url = str_replace( home_url(), 'http://some-other-domain.com', get_permalink( $post_id ) );442 $url = str_replace( home_url(), 'http://some-other-domain.com', get_permalink( $post_id ) ); 371 443 372 444 $this->assertSame( $post_id, url_to_postid( $permalink ) ); … … 380 452 $this->set_permalink_structure( '/%postname%/' ); 381 453 382 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_status' => 'trash' ) ); 454 $page_id = self::factory()->post->create( 455 array( 456 'post_type' => 'page', 457 'post_status' => 'trash', 458 ) 459 ); 383 460 $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); 384 461
Note: See TracChangeset
for help on using the changeset viewer.