Changeset 42343 for trunk/tests/phpunit/tests/query/conditionals.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/query/conditionals.php (modified) (70 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/conditionals.php
r39599 r42343 29 29 30 30 function test_home() { 31 $this->go_to( '/');31 $this->go_to( '/' ); 32 32 $this->assertQueryTrue( 'is_home', 'is_front_page' ); 33 33 } 34 34 35 35 function test_page_on_front() { 36 $page_on_front = self::factory()->post->create( array( 37 'post_type' => 'page', 38 ) ); 39 $page_for_posts = self::factory()->post->create( array( 40 'post_type' => 'page', 41 ) ); 36 $page_on_front = self::factory()->post->create( 37 array( 38 'post_type' => 'page', 39 ) 40 ); 41 $page_for_posts = self::factory()->post->create( 42 array( 43 'post_type' => 'page', 44 ) 45 ); 42 46 update_option( 'show_on_front', 'page' ); 43 47 update_option( 'page_on_front', $page_on_front ); … … 57 61 function test_404() { 58 62 $this->go_to( '/notapage' ); 59 $this->assertQueryTrue( 'is_404');63 $this->assertQueryTrue( 'is_404' ); 60 64 } 61 65 … … 63 67 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 64 68 $this->go_to( get_permalink( $post_id ) ); 65 $this->assertQueryTrue( 'is_single', 'is_singular');69 $this->assertQueryTrue( 'is_single', 'is_singular' ); 66 70 } 67 71 … … 70 74 self::factory()->comment->create_post_comments( $post_id, 2 ); 71 75 $this->go_to( get_post_comments_feed_link( $post_id ) ); 72 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed');76 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed' ); 73 77 } 74 78 … … 77 81 $post_id = self::factory()->post->create( array( 'post_title' => 'hello-world' ) ); 78 82 $this->go_to( get_post_comments_feed_link( $post_id ) ); 79 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed');83 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed' ); 80 84 } 81 85 … … 88 92 89 93 function test_page() { 90 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about' ) ); 94 $page_id = self::factory()->post->create( 95 array( 96 'post_type' => 'page', 97 'post_title' => 'about', 98 ) 99 ); 91 100 $this->go_to( get_permalink( $page_id ) ); 92 $this->assertQueryTrue( 'is_page','is_singular');101 $this->assertQueryTrue( 'is_page', 'is_singular' ); 93 102 } 94 103 95 104 function test_parent_page() { 96 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 105 $page_id = self::factory()->post->create( 106 array( 107 'post_type' => 'page', 108 'post_title' => 'parent-page', 109 ) 110 ); 97 111 $this->go_to( get_permalink( $page_id ) ); 98 112 99 $this->assertQueryTrue( 'is_page','is_singular');113 $this->assertQueryTrue( 'is_page', 'is_singular' ); 100 114 } 101 115 102 116 function test_child_page_1() { 103 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 104 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 117 $page_id = self::factory()->post->create( 118 array( 119 'post_type' => 'page', 120 'post_title' => 'parent-page', 121 ) 122 ); 123 $page_id = self::factory()->post->create( 124 array( 125 'post_type' => 'page', 126 'post_title' => 'child-page-1', 127 'post_parent' => $page_id, 128 ) 129 ); 105 130 $this->go_to( get_permalink( $page_id ) ); 106 131 107 $this->assertQueryTrue( 'is_page','is_singular');132 $this->assertQueryTrue( 'is_page', 'is_singular' ); 108 133 } 109 134 110 135 function test_child_page_2() { 111 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 112 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 113 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); 136 $page_id = self::factory()->post->create( 137 array( 138 'post_type' => 'page', 139 'post_title' => 'parent-page', 140 ) 141 ); 142 $page_id = self::factory()->post->create( 143 array( 144 'post_type' => 'page', 145 'post_title' => 'child-page-1', 146 'post_parent' => $page_id, 147 ) 148 ); 149 $page_id = self::factory()->post->create( 150 array( 151 'post_type' => 'page', 152 'post_title' => 'child-page-2', 153 'post_parent' => $page_id, 154 ) 155 ); 114 156 $this->go_to( get_permalink( $page_id ) ); 115 157 116 $this->assertQueryTrue( 'is_page','is_singular');158 $this->assertQueryTrue( 'is_page', 'is_singular' ); 117 159 } 118 160 119 161 // '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1' 120 162 function test_page_trackback() { 121 $page_ids = array(); 122 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 123 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 124 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); 163 $page_ids = array(); 164 $page_ids[] = $page_id = self::factory()->post->create( 165 array( 166 'post_type' => 'page', 167 'post_title' => 'parent-page', 168 ) 169 ); 170 $page_ids[] = $page_id = self::factory()->post->create( 171 array( 172 'post_type' => 'page', 173 'post_title' => 'child-page-1', 174 'post_parent' => $page_id, 175 ) 176 ); 177 $page_ids[] = $page_id = self::factory()->post->create( 178 array( 179 'post_type' => 'page', 180 'post_title' => 'child-page-2', 181 'post_parent' => $page_id, 182 ) 183 ); 125 184 foreach ( $page_ids as $page_id ) { 126 185 $url = get_permalink( $page_id ); 127 $this->go_to( "{$url}trackback/");186 $this->go_to( "{$url}trackback/" ); 128 187 129 188 // make sure the correct wp_query flags are set 130 $this->assertQueryTrue( 'is_page','is_singular','is_trackback');189 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_trackback' ); 131 190 132 191 // make sure the correct page was fetched … … 138 197 //'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' 139 198 function test_page_feed() { 140 $page_ids = array(); 141 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 142 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 143 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); 199 $page_ids = array(); 200 $page_ids[] = $page_id = self::factory()->post->create( 201 array( 202 'post_type' => 'page', 203 'post_title' => 'parent-page', 204 ) 205 ); 206 $page_ids[] = $page_id = self::factory()->post->create( 207 array( 208 'post_type' => 'page', 209 'post_title' => 'child-page-1', 210 'post_parent' => $page_id, 211 ) 212 ); 213 $page_ids[] = $page_id = self::factory()->post->create( 214 array( 215 'post_type' => 'page', 216 'post_title' => 'child-page-2', 217 'post_parent' => $page_id, 218 ) 219 ); 144 220 foreach ( $page_ids as $page_id ) { 145 221 self::factory()->comment->create_post_comments( $page_id, 2 ); 146 222 $url = get_permalink( $page_id ); 147 $this->go_to( "{$url}feed/");223 $this->go_to( "{$url}feed/" ); 148 224 149 225 // make sure the correct wp_query flags are set 150 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed');226 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed' ); 151 227 152 228 // make sure the correct page was fetched … … 157 233 158 234 function test_page_feed_with_no_comments() { 159 $page_ids = array(); 160 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 161 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 162 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); 235 $page_ids = array(); 236 $page_ids[] = $page_id = self::factory()->post->create( 237 array( 238 'post_type' => 'page', 239 'post_title' => 'parent-page', 240 ) 241 ); 242 $page_ids[] = $page_id = self::factory()->post->create( 243 array( 244 'post_type' => 'page', 245 'post_title' => 'child-page-1', 246 'post_parent' => $page_id, 247 ) 248 ); 249 $page_ids[] = $page_id = self::factory()->post->create( 250 array( 251 'post_type' => 'page', 252 'post_title' => 'child-page-2', 253 'post_parent' => $page_id, 254 ) 255 ); 163 256 foreach ( $page_ids as $page_id ) { 164 257 $url = get_permalink( $page_id ); 165 $this->go_to( "{$url}feed/");258 $this->go_to( "{$url}feed/" ); 166 259 167 260 // make sure the correct wp_query flags are set 168 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed');261 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed' ); 169 262 170 263 // make sure the correct page was fetched … … 176 269 // '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]' 177 270 function test_page_feed_atom() { 178 $page_ids = array(); 179 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'parent-page' ) ); 180 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-1', 'post_parent' => $page_id ) ); 181 $page_ids[] = $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'child-page-2', 'post_parent' => $page_id ) ); 271 $page_ids = array(); 272 $page_ids[] = $page_id = self::factory()->post->create( 273 array( 274 'post_type' => 'page', 275 'post_title' => 'parent-page', 276 ) 277 ); 278 $page_ids[] = $page_id = self::factory()->post->create( 279 array( 280 'post_type' => 'page', 281 'post_title' => 'child-page-1', 282 'post_parent' => $page_id, 283 ) 284 ); 285 $page_ids[] = $page_id = self::factory()->post->create( 286 array( 287 'post_type' => 'page', 288 'post_title' => 'child-page-2', 289 'post_parent' => $page_id, 290 ) 291 ); 182 292 foreach ( $page_ids as $page_id ) { 183 293 self::factory()->comment->create_post_comments( $page_id, 2 ); 184 294 185 295 $url = get_permalink( $page_id ); 186 $this->go_to( "{$url}feed/atom/");296 $this->go_to( "{$url}feed/atom/" ); 187 297 188 298 // make sure the correct wp_query flags are set 189 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed');299 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_feed', 'is_comment_feed' ); 190 300 191 301 // make sure the correct page was fetched … … 197 307 // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' 198 308 function test_page_page_2() { 199 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); 200 $this->go_to("/about/page/2/"); 309 $page_id = self::factory()->post->create( 310 array( 311 'post_type' => 'page', 312 'post_title' => 'about', 313 'post_content' => 'Page 1 <!--nextpage--> Page 2', 314 ) 315 ); 316 $this->go_to( '/about/page/2/' ); 201 317 202 318 // make sure the correct wp_query flags are set 203 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_paged');319 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_paged' ); 204 320 205 321 // make sure the correct page was fetched … … 210 326 // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' 211 327 function test_page_page_2_no_slash() { 212 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); 213 $this->go_to("/about/page2/"); 328 $page_id = self::factory()->post->create( 329 array( 330 'post_type' => 'page', 331 'post_title' => 'about', 332 'post_content' => 'Page 1 <!--nextpage--> Page 2', 333 ) 334 ); 335 $this->go_to( '/about/page2/' ); 214 336 215 337 // make sure the correct wp_query flags are set 216 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_paged');338 $this->assertQueryTrue( 'is_page', 'is_singular', 'is_paged' ); 217 339 218 340 // make sure the correct page was fetched … … 223 345 // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' 224 346 function test_pagination_of_posts_page() { 225 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'about', 'post_content' => 'Page 1 <!--nextpage--> Page 2' ) ); 347 $page_id = self::factory()->post->create( 348 array( 349 'post_type' => 'page', 350 'post_title' => 'about', 351 'post_content' => 'Page 1 <!--nextpage--> Page 2', 352 ) 353 ); 226 354 update_option( 'show_on_front', 'page' ); 227 355 update_option( 'page_for_posts', $page_id ); 228 356 229 $this->go_to( '/about/2/');357 $this->go_to( '/about/2/' ); 230 358 231 359 $this->assertQueryTrue( 'is_home', 'is_posts_page' ); … … 249 377 function test_main_feed_2() { 250 378 self::factory()->post->create(); // @test_404 251 $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');379 $feeds = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 252 380 253 381 // long version 254 foreach ( $feeds as $feed) {255 $this->go_to( "/feed/{$feed}/");256 $this->assertQueryTrue( 'is_feed');382 foreach ( $feeds as $feed ) { 383 $this->go_to( "/feed/{$feed}/" ); 384 $this->assertQueryTrue( 'is_feed' ); 257 385 } 258 386 259 387 // short version 260 foreach ( $feeds as $feed) {261 $this->go_to( "/{$feed}/");262 $this->assertQueryTrue( 'is_feed');388 foreach ( $feeds as $feed ) { 389 $this->go_to( "/{$feed}/" ); 390 $this->assertQueryTrue( 'is_feed' ); 263 391 } 264 392 … … 267 395 function test_main_feed() { 268 396 self::factory()->post->create(); // @test_404 269 $types = array( 'rss2', 'rss', 'atom');270 foreach ( $types as $type) {271 $this->go_to( get_feed_link($type));272 $this->assertQueryTrue( 'is_feed');397 $types = array( 'rss2', 'rss', 'atom' ); 398 foreach ( $types as $type ) { 399 $this->go_to( get_feed_link( $type ) ); 400 $this->assertQueryTrue( 'is_feed' ); 273 401 } 274 402 } … … 279 407 self::factory()->post->create_many( 5 ); 280 408 for ( $i = 2; $i <= 3; $i++ ) { 281 $this->go_to( "/page/{$i}/");409 $this->go_to( "/page/{$i}/" ); 282 410 $this->assertQueryTrue( 'is_home', 'is_front_page', 'is_paged' ); 283 411 } … … 292 420 // check the url as generated by get_post_comments_feed_link() 293 421 $this->go_to( get_post_comments_feed_link( $post_id ) ); 294 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed');422 $this->assertQueryTrue( 'is_feed', 'is_single', 'is_singular', 'is_comment_feed' ); 295 423 296 424 // check the long form 297 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');298 foreach ( $types as $type) {299 $this->go_to( "/comments/feed/{$type}");300 $this->assertQueryTrue( 'is_feed', 'is_comment_feed');425 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 426 foreach ( $types as $type ) { 427 $this->go_to( "/comments/feed/{$type}" ); 428 $this->assertQueryTrue( 'is_feed', 'is_comment_feed' ); 301 429 } 302 430 303 431 // check the short form 304 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');305 foreach ( $types as $type) {306 $this->go_to( "/comments/{$type}");307 $this->assertQueryTrue( 'is_feed', 'is_comment_feed');432 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 433 foreach ( $types as $type ) { 434 $this->go_to( "/comments/{$type}" ); 435 $this->assertQueryTrue( 'is_feed', 'is_comment_feed' ); 308 436 } 309 437 … … 314 442 function test_search_feed() { 315 443 // check the long form 316 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');317 foreach ( $types as $type) {318 $this->go_to( "/search/test/feed/{$type}");319 $this->assertQueryTrue( 'is_feed', 'is_search');444 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 445 foreach ( $types as $type ) { 446 $this->go_to( "/search/test/feed/{$type}" ); 447 $this->assertQueryTrue( 'is_feed', 'is_search' ); 320 448 } 321 449 322 450 // check the short form 323 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');324 foreach ( $types as $type) {325 $this->go_to( "/search/test/{$type}");326 $this->assertQueryTrue( 'is_feed', 'is_search');451 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 452 foreach ( $types as $type ) { 453 $this->go_to( "/search/test/{$type}" ); 454 $this->assertQueryTrue( 'is_feed', 'is_search' ); 327 455 } 328 456 } … … 332 460 update_option( 'posts_per_page', 2 ); 333 461 self::factory()->post->create_many( 3, array( 'post_title' => 'test' ) ); 334 $this->go_to( '/search/test/page/2/');335 $this->assertQueryTrue( 'is_search', 'is_paged');462 $this->go_to( '/search/test/page/2/' ); 463 $this->assertQueryTrue( 'is_search', 'is_paged' ); 336 464 } 337 465 338 466 // 'search/(.+)/?$' => 'index.php?s=$matches[1]', 339 467 function test_search() { 340 $this->go_to( '/search/test/');341 $this->assertQueryTrue( 'is_search');468 $this->go_to( '/search/test/' ); 469 $this->assertQueryTrue( 'is_search' ); 342 470 } 343 471 … … 346 474 */ 347 475 function test_search_encoded_chars() { 348 $this->go_to( '/search/F%C3%BCnf%2Bbar/');476 $this->go_to( '/search/F%C3%BCnf%2Bbar/' ); 349 477 $this->assertEquals( get_query_var( 's' ), 'Fünf+bar' ); 350 478 } … … 353 481 // 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 354 482 function test_category_feed() { 355 self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); 483 self::factory()->term->create( 484 array( 485 'name' => 'cat-a', 486 'taxonomy' => 'category', 487 ) 488 ); 356 489 357 490 // check the long form 358 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');359 foreach ( $types as $type) {360 $this->go_to( "/category/cat-a/feed/{$type}");361 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_category');491 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 492 foreach ( $types as $type ) { 493 $this->go_to( "/category/cat-a/feed/{$type}" ); 494 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_category' ); 362 495 } 363 496 364 497 // check the short form 365 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');366 foreach ( $types as $type) {367 $this->go_to( "/category/cat-a/{$type}");368 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_category');498 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 499 foreach ( $types as $type ) { 500 $this->go_to( "/category/cat-a/{$type}" ); 501 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_category' ); 369 502 } 370 503 } … … 374 507 update_option( 'posts_per_page', 2 ); 375 508 self::factory()->post->create_many( 3 ); 376 $this->go_to( '/category/uncategorized/page/2/');377 $this->assertQueryTrue( 'is_archive', 'is_category', 'is_paged');509 $this->go_to( '/category/uncategorized/page/2/' ); 510 $this->assertQueryTrue( 'is_archive', 'is_category', 'is_paged' ); 378 511 } 379 512 380 513 // 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', 381 514 function test_category() { 382 self::factory()->term->create( array( 'name' => 'cat-a', 'taxonomy' => 'category' ) ); 383 $this->go_to('/category/cat-a/'); 384 $this->assertQueryTrue('is_archive', 'is_category'); 515 self::factory()->term->create( 516 array( 517 'name' => 'cat-a', 518 'taxonomy' => 'category', 519 ) 520 ); 521 $this->go_to( '/category/cat-a/' ); 522 $this->assertQueryTrue( 'is_archive', 'is_category' ); 385 523 } 386 524 … … 388 526 // 'tag/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 389 527 function test_tag_feed() { 390 self::factory()->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) ); 528 self::factory()->term->create( 529 array( 530 'name' => 'tag-a', 531 'taxonomy' => 'post_tag', 532 ) 533 ); 391 534 // check the long form 392 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');393 foreach ( $types as $type) {394 $this->go_to( "/tag/tag-a/feed/{$type}");395 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_tag');535 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 536 foreach ( $types as $type ) { 537 $this->go_to( "/tag/tag-a/feed/{$type}" ); 538 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_tag' ); 396 539 } 397 540 398 541 // check the short form 399 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');400 foreach ( $types as $type) {401 $this->go_to( "/tag/tag-a/{$type}");402 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_tag');542 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 543 foreach ( $types as $type ) { 544 $this->go_to( "/tag/tag-a/{$type}" ); 545 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_tag' ); 403 546 } 404 547 } … … 408 551 update_option( 'posts_per_page', 2 ); 409 552 $post_ids = self::factory()->post->create_many( 3 ); 410 foreach ( $post_ids as $post_id ) 553 foreach ( $post_ids as $post_id ) { 411 554 self::factory()->term->add_post_terms( $post_id, 'tag-a', 'post_tag' ); 412 $this->go_to('/tag/tag-a/page/2/'); 413 $this->assertQueryTrue('is_archive', 'is_tag', 'is_paged'); 555 } 556 $this->go_to( '/tag/tag-a/page/2/' ); 557 $this->assertQueryTrue( 'is_archive', 'is_tag', 'is_paged' ); 414 558 } 415 559 416 560 // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]', 417 561 function test_tag() { 418 $term_id = self::factory()->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) ); 419 $this->go_to('/tag/tag-a/'); 420 $this->assertQueryTrue('is_archive', 'is_tag'); 562 $term_id = self::factory()->term->create( 563 array( 564 'name' => 'Tag Named A', 565 'slug' => 'tag-a', 566 'taxonomy' => 'post_tag', 567 ) 568 ); 569 $this->go_to( '/tag/tag-a/' ); 570 $this->assertQueryTrue( 'is_archive', 'is_tag' ); 421 571 422 572 $tag = get_term( $term_id, 'post_tag' ); … … 437 587 self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 438 588 // check the long form 439 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');440 foreach ( $types as $type) {441 $this->go_to( "/author/user-a/feed/{$type}");442 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_author');589 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 590 foreach ( $types as $type ) { 591 $this->go_to( "/author/user-a/feed/{$type}" ); 592 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_author' ); 443 593 } 444 594 445 595 // check the short form 446 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');447 foreach ( $types as $type) {448 $this->go_to( "/author/user-a/{$type}");449 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_author');596 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 597 foreach ( $types as $type ) { 598 $this->go_to( "/author/user-a/{$type}" ); 599 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_author' ); 450 600 } 451 601 } … … 456 606 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 457 607 self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) ); 458 $this->go_to( '/author/user-a/page/2/');459 $this->assertQueryTrue( 'is_archive', 'is_author', 'is_paged');608 $this->go_to( '/author/user-a/page/2/' ); 609 $this->assertQueryTrue( 'is_archive', 'is_author', 'is_paged' ); 460 610 } 461 611 … … 464 614 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 465 615 self::factory()->post->create( array( 'post_author' => $user_id ) ); 466 $this->go_to( '/author/user-a/');467 $this->assertQueryTrue( 'is_archive', 'is_author');616 $this->go_to( '/author/user-a/' ); 617 $this->assertQueryTrue( 'is_archive', 'is_author' ); 468 618 } 469 619 470 620 function test_author_with_no_posts() { 471 621 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) ); 472 $this->go_to( '/author/user-a/');473 $this->assertQueryTrue( 'is_archive', 'is_author');622 $this->go_to( '/author/user-a/' ); 623 $this->assertQueryTrue( 'is_archive', 'is_author' ); 474 624 } 475 625 … … 479 629 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 480 630 // check the long form 481 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');482 foreach ( $types as $type) {483 $this->go_to( "/2007/09/04/feed/{$type}");484 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_day', 'is_date');631 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 632 foreach ( $types as $type ) { 633 $this->go_to( "/2007/09/04/feed/{$type}" ); 634 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_day', 'is_date' ); 485 635 } 486 636 487 637 // check the short form 488 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');489 foreach ( $types as $type) {490 $this->go_to( "/2007/09/04/{$type}");491 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_day', 'is_date');638 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 639 foreach ( $types as $type ) { 640 $this->go_to( "/2007/09/04/{$type}" ); 641 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_day', 'is_date' ); 492 642 } 493 643 } … … 497 647 update_option( 'posts_per_page', 2 ); 498 648 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 499 $this->go_to( '/2007/09/04/page/2/');500 $this->assertQueryTrue( 'is_archive', 'is_day', 'is_date', 'is_paged');649 $this->go_to( '/2007/09/04/page/2/' ); 650 $this->assertQueryTrue( 'is_archive', 'is_day', 'is_date', 'is_paged' ); 501 651 } 502 652 … … 504 654 function test_ymd() { 505 655 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 506 $this->go_to( '/2007/09/04/');507 $this->assertQueryTrue( 'is_archive', 'is_day', 'is_date');656 $this->go_to( '/2007/09/04/' ); 657 $this->assertQueryTrue( 'is_archive', 'is_day', 'is_date' ); 508 658 } 509 659 … … 513 663 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 514 664 // check the long form 515 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');516 foreach ( $types as $type) {517 $this->go_to( "/2007/09/feed/{$type}");518 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_month', 'is_date');665 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 666 foreach ( $types as $type ) { 667 $this->go_to( "/2007/09/feed/{$type}" ); 668 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_month', 'is_date' ); 519 669 } 520 670 521 671 // check the short form 522 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');523 foreach ( $types as $type) {524 $this->go_to( "/2007/09/{$type}");525 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_month', 'is_date');672 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 673 foreach ( $types as $type ) { 674 $this->go_to( "/2007/09/{$type}" ); 675 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_month', 'is_date' ); 526 676 } 527 677 } … … 531 681 update_option( 'posts_per_page', 2 ); 532 682 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 533 $this->go_to( '/2007/09/page/2/');534 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_month', 'is_paged');683 $this->go_to( '/2007/09/page/2/' ); 684 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_month', 'is_paged' ); 535 685 } 536 686 … … 538 688 function test_ym() { 539 689 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 540 $this->go_to( '/2007/09/');541 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_month');690 $this->go_to( '/2007/09/' ); 691 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_month' ); 542 692 } 543 693 … … 547 697 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 548 698 // check the long form 549 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');550 foreach ( $types as $type) {551 $this->go_to( "/2007/feed/{$type}");552 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_year', 'is_date');699 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 700 foreach ( $types as $type ) { 701 $this->go_to( "/2007/feed/{$type}" ); 702 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_year', 'is_date' ); 553 703 } 554 704 555 705 // check the short form 556 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');557 foreach ( $types as $type) {558 $this->go_to( "/2007/{$type}");559 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_year', 'is_date');706 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 707 foreach ( $types as $type ) { 708 $this->go_to( "/2007/{$type}" ); 709 $this->assertQueryTrue( 'is_archive', 'is_feed', 'is_year', 'is_date' ); 560 710 } 561 711 } … … 565 715 update_option( 'posts_per_page', 2 ); 566 716 self::factory()->post->create_many( 3, array( 'post_date' => '2007-09-04 00:00:00' ) ); 567 $this->go_to( '/2007/page/2/');568 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_year', 'is_paged');717 $this->go_to( '/2007/page/2/' ); 718 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_year', 'is_paged' ); 569 719 } 570 720 … … 572 722 function test_y() { 573 723 self::factory()->post->create( array( 'post_date' => '2007-09-04 00:00:00' ) ); 574 $this->go_to( '/2007/');575 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_year');724 $this->go_to( '/2007/' ); 725 $this->assertQueryTrue( 'is_archive', 'is_date', 'is_year' ); 576 726 } 577 727 578 728 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', 579 729 function test_post_trackback() { 580 $post_id = self::factory()->post->create();730 $post_id = self::factory()->post->create(); 581 731 $permalink = get_permalink( $post_id ); 582 $this->go_to( "{$permalink}trackback/");583 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_trackback');732 $this->go_to( "{$permalink}trackback/" ); 733 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_trackback' ); 584 734 } 585 735 … … 587 737 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', 588 738 function test_post_comment_feed() { 589 $post_id = self::factory()->post->create();739 $post_id = self::factory()->post->create(); 590 740 $permalink = get_permalink( $post_id ); 591 741 592 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');593 foreach ( $types as $type) {594 $this->go_to( "{$permalink}feed/{$type}");595 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_feed', 'is_comment_feed');742 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 743 foreach ( $types as $type ) { 744 $this->go_to( "{$permalink}feed/{$type}" ); 745 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_feed', 'is_comment_feed' ); 596 746 } 597 747 598 748 // check the short form 599 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom');600 foreach ( $types as $type) {601 $this->go_to( "{$permalink}{$type}");602 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_feed', 'is_comment_feed');749 $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 750 foreach ( $types as $type ) { 751 $this->go_to( "{$permalink}{$type}" ); 752 $this->assertQueryTrue( 'is_single', 'is_singular', 'is_feed', 'is_comment_feed' ); 603 753 } 604 754 } … … 606 756 // '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', 607 757 function test_post_paged_short() { 608 $post_id = self::factory()->post->create( array( 609 'post_date' => '2007-09-04 00:00:00', 610 'post_title' => 'a-post-with-multiple-pages', 611 'post_content' => 'Page 1 <!--nextpage--> Page 2' 612 ) ); 758 $post_id = self::factory()->post->create( 759 array( 760 'post_date' => '2007-09-04 00:00:00', 761 'post_title' => 'a-post-with-multiple-pages', 762 'post_content' => 'Page 1 <!--nextpage--> Page 2', 763 ) 764 ); 613 765 $this->go_to( get_permalink( $post_id ) . '2/' ); 614 766 // should is_paged be true also? 615 $this->assertQueryTrue( 'is_single', 'is_singular');767 $this->assertQueryTrue( 'is_single', 'is_singular' ); 616 768 617 769 } … … 619 771 // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 620 772 function test_post_attachment() { 621 $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) );773 $post_id = self::factory()->post->create( array( 'post_type' => 'attachment' ) ); 622 774 $permalink = get_attachment_link( $post_id ); 623 $this->go_to( $permalink);624 $this->assertQueryTrue( 'is_single', 'is_attachment', 'is_singular');775 $this->go_to( $permalink ); 776 $this->assertQueryTrue( 'is_single', 'is_attachment', 'is_singular' ); 625 777 } 626 778 … … 648 800 649 801 $cpt_name = 'ptawtq'; 650 register_post_type( $cpt_name, array( 651 'taxonomies' => array( 'post_tag', 'category' ), 652 'rewrite' => true, 653 'has_archive' => true, 654 'public' => true 655 ) ); 656 657 $tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); 802 register_post_type( 803 $cpt_name, array( 804 'taxonomies' => array( 'post_tag', 'category' ), 805 'rewrite' => true, 806 'has_archive' => true, 807 'public' => true, 808 ) 809 ); 810 811 $tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); 658 812 $post_id = self::factory()->post->create( array( 'post_type' => $cpt_name ) ); 659 813 wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); … … 674 828 function pre_get_posts_with_tax_query( &$query ) { 675 829 $term = get_term_by( 'slug', 'tag-slug', 'post_tag' ); 676 $query->set( 'tax_query', array( 677 array( 'taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $term->term_id ) 678 ) ); 830 $query->set( 831 'tax_query', array( 832 array( 833 'taxonomy' => 'post_tag', 834 'field' => 'term_id', 835 'terms' => $term->term_id, 836 ), 837 ) 838 ); 679 839 } 680 840 … … 683 843 684 844 $cpt_name = 'thearray'; 685 register_post_type( $cpt_name, array( 686 'taxonomies' => array( 'post_tag', 'category' ), 687 'rewrite' => true, 688 'has_archive' => true, 689 'public' => true 690 ) ); 845 register_post_type( 846 $cpt_name, array( 847 'taxonomies' => array( 'post_tag', 'category' ), 848 'rewrite' => true, 849 'has_archive' => true, 850 'public' => true, 851 ) 852 ); 691 853 self::factory()->post->create( array( 'post_type' => $cpt_name ) ); 692 854 … … 713 875 714 876 $post = get_queried_object(); 715 $q = $GLOBALS['wp_query'];877 $q = $GLOBALS['wp_query']; 716 878 717 879 $this->assertTrue( is_single() ); … … 732 894 $post_type = 'test_hierarchical'; 733 895 734 register_post_type( $post_type, array( 735 'hierarchical' => true, 736 'rewrite' => true, 737 'has_archive' => true, 738 'public' => true 739 ) ); 896 register_post_type( 897 $post_type, array( 898 'hierarchical' => true, 899 'rewrite' => true, 900 'has_archive' => true, 901 'public' => true, 902 ) 903 ); 740 904 741 905 // Create parent and child posts 742 $parent_id = self::factory()->post->create( array( 743 'post_type' => $post_type, 744 'post_name' => 'foo' 745 ) ); 746 747 $post_id = self::factory()->post->create( array( 748 'post_type' => $post_type, 749 'post_name' => 'bar', 750 'post_parent' => $parent_id 751 ) ); 906 $parent_id = self::factory()->post->create( 907 array( 908 'post_type' => $post_type, 909 'post_name' => 'foo', 910 ) 911 ); 912 913 $post_id = self::factory()->post->create( 914 array( 915 'post_type' => $post_type, 916 'post_name' => 'bar', 917 'post_parent' => $parent_id, 918 ) 919 ); 752 920 753 921 // Tests … … 755 923 756 924 $post = get_queried_object(); 757 $q = $GLOBALS['wp_query'];925 $q = $GLOBALS['wp_query']; 758 926 759 927 $this->assertTrue( is_single() ); … … 779 947 780 948 $p2_name = $p1 . '-post'; 781 $p2 = self::factory()->post->create( array( 782 'slug' => $p2_name, 783 ) ); 949 $p2 = self::factory()->post->create( 950 array( 951 'slug' => $p2_name, 952 ) 953 ); 784 954 785 955 $this->go_to( "/?p=$p1" ); … … 799 969 $this->set_permalink_structure( '/%postname%/' ); 800 970 801 $attachment_id = $this->factory->post->create( array( 802 'post_type' => 'attachment', 803 ) ); 804 805 $post_id = $this->factory->post->create( array( 806 'post_title' => get_post( $attachment_id )->post_title 807 ) ); 971 $attachment_id = $this->factory->post->create( 972 array( 973 'post_type' => 'attachment', 974 ) 975 ); 976 977 $post_id = $this->factory->post->create( 978 array( 979 'post_title' => get_post( $attachment_id )->post_title, 980 ) 981 ); 808 982 809 983 $this->go_to( get_permalink( $post_id ) ); … … 825 999 $post_id = self::factory()->post->create(); 826 1000 827 $attachment_id = self::factory()->attachment->create_object( 'image.jpg', $post_id, array( 828 'post_mime_type' => 'image/jpeg', 829 ) ); 1001 $attachment_id = self::factory()->attachment->create_object( 1002 'image.jpg', $post_id, array( 1003 'post_mime_type' => 'image/jpeg', 1004 ) 1005 ); 830 1006 831 1007 $this->go_to( get_permalink( $attachment_id ) ); … … 843 1019 844 1020 $post = get_queried_object(); 845 $q = $GLOBALS['wp_query'];1021 $q = $GLOBALS['wp_query']; 846 1022 847 1023 $this->assertTrue( is_page() ); … … 859 1035 */ 860 1036 function test_is_page_with_parent() { 861 $parent_id = self::factory()->post->create( array( 862 'post_type' => 'page', 863 'post_name' => 'foo', 864 ) ); 865 $post_id = self::factory()->post->create( array( 866 'post_type' => 'page', 867 'post_name' => 'bar', 868 'post_parent' => $parent_id, 869 ) ); 1037 $parent_id = self::factory()->post->create( 1038 array( 1039 'post_type' => 'page', 1040 'post_name' => 'foo', 1041 ) 1042 ); 1043 $post_id = self::factory()->post->create( 1044 array( 1045 'post_type' => 'page', 1046 'post_name' => 'bar', 1047 'post_parent' => $parent_id, 1048 ) 1049 ); 870 1050 $this->go_to( "/?page_id=$post_id" ); 871 1051 872 1052 $post = get_queried_object(); 873 $q = $GLOBALS['wp_query'];1053 $q = $GLOBALS['wp_query']; 874 1054 875 1055 $this->assertTrue( is_page() ); … … 893 1073 894 1074 $post = get_queried_object(); 895 $q = $GLOBALS['wp_query'];1075 $q = $GLOBALS['wp_query']; 896 1076 897 1077 $this->assertTrue( is_attachment() ); … … 913 1093 914 1094 $p2_name = $p1 . '-attachment'; 915 $p2 = self::factory()->post->create( array( 916 'post_type' => 'attachment', 917 'post_name' => $p2_name, 918 ) ); 1095 $p2 = self::factory()->post->create( 1096 array( 1097 'post_type' => 'attachment', 1098 'post_name' => $p2_name, 1099 ) 1100 ); 919 1101 920 1102 $this->go_to( "/?attachment_id=$p1" ); … … 935 1117 936 1118 $u2_name = $u1 . '_user'; 937 $u2 = self::factory()->user->create( array( 938 'user_nicename' => $u2_name, 939 ) ); 1119 $u2 = self::factory()->user->create( 1120 array( 1121 'user_nicename' => $u2_name, 1122 ) 1123 ); 940 1124 941 1125 $this->go_to( "/?author=$u1" ); … … 956 1140 957 1141 $c2_name = $c1 . '-category'; 958 $c2 = self::factory()->category->create( array( 959 'slug' => $c2_name, 960 ) ); 1142 $c2 = self::factory()->category->create( 1143 array( 1144 'slug' => $c2_name, 1145 ) 1146 ); 961 1147 962 1148 $this->go_to( "/?cat=$c1" ); … … 977 1163 978 1164 $t2_name = $t1 . '-tag'; 979 $t2 = self::factory()->tag->create( array( 980 'slug' => $t2_name, 981 ) ); 1165 $t2 = self::factory()->tag->create( 1166 array( 1167 'slug' => $t2_name, 1168 ) 1169 ); 982 1170 983 1171 $this->go_to( "/?tag_id=$t1" ); … … 999 1187 1000 1188 // override post ID to 0 temporarily for testing 1001 $_id = $GLOBALS['wp_query']->post->ID;1189 $_id = $GLOBALS['wp_query']->post->ID; 1002 1190 $GLOBALS['wp_query']->post->ID = 0; 1003 1191 1004 1192 $post = get_queried_object(); 1005 $q = $GLOBALS['wp_query'];1193 $q = $GLOBALS['wp_query']; 1006 1194 1007 1195 $this->assertTrue( $q->is_page() ); … … 1020 1208 1021 1209 $p2_name = $p1 . '-page'; 1022 $p2 = self::factory()->post->create( array( 1023 'post_type' => 'page', 1024 'post_name' => $p2_name, 1025 ) ); 1210 $p2 = self::factory()->post->create( 1211 array( 1212 'post_type' => 'page', 1213 'post_name' => $p2_name, 1214 ) 1215 ); 1026 1216 1027 1217 $this->go_to( "/?page_id=$p1" ); … … 1037 1227 function test_is_page_template() { 1038 1228 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1039 update_post_meta( $post_id, '_wp_page_template', 'example.php');1229 update_post_meta( $post_id, '_wp_page_template', 'example.php' ); 1040 1230 $this->go_to( "/?page_id=$post_id" ); 1041 1231 $this->assertTrue( is_page_template( 'example.php' ) ); … … 1057 1247 function test_is_page_template_array() { 1058 1248 $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 1059 update_post_meta( $post_id, '_wp_page_template', 'example.php');1249 update_post_meta( $post_id, '_wp_page_template', 'example.php' ); 1060 1250 $this->go_to( "/?page_id=$post_id" ); 1061 1251 $this->assertFalse( is_page_template( array( 'test.php' ) ) ); 1062 $this->assertTrue( is_page_template( array( 'test.php', 'example.php') ) );1252 $this->assertTrue( is_page_template( array( 'test.php', 'example.php' ) ) ); 1063 1253 } 1064 1254 … … 1104 1294 */ 1105 1295 public function test_is_attachment_should_not_match_numeric_id_to_post_title_beginning_with_id() { 1106 $p1 = self::factory()->post->create( array( 1107 'post_type' => 'attachment', 1108 'post_title' => 'Foo', 1109 'post_name' => 'foo', 1110 ) ); 1111 $p2 = self::factory()->post->create( array( 1112 'post_type' => 'attachment', 1113 'post_title' => "$p1 Foo", 1114 'post_name' => 'foo-2', 1115 ) ); 1296 $p1 = self::factory()->post->create( 1297 array( 1298 'post_type' => 'attachment', 1299 'post_title' => 'Foo', 1300 'post_name' => 'foo', 1301 ) 1302 ); 1303 $p2 = self::factory()->post->create( 1304 array( 1305 'post_type' => 'attachment', 1306 'post_title' => "$p1 Foo", 1307 'post_name' => 'foo-2', 1308 ) 1309 ); 1116 1310 1117 1311 $this->go_to( get_permalink( $p2 ) ); … … 1125 1319 */ 1126 1320 public function test_is_attachment_should_not_match_numeric_id_to_post_name_beginning_with_id() { 1127 $p1 = self::factory()->post->create( array( 1128 'post_type' => 'attachment', 1129 'post_title' => 'Foo', 1130 'post_name' => 'foo', 1131 ) ); 1132 $p2 = self::factory()->post->create( array( 1133 'post_type' => 'attachment', 1134 'post_title' => 'Foo', 1135 'post_name' => "$p1-foo", 1136 ) ); 1321 $p1 = self::factory()->post->create( 1322 array( 1323 'post_type' => 'attachment', 1324 'post_title' => 'Foo', 1325 'post_name' => 'foo', 1326 ) 1327 ); 1328 $p2 = self::factory()->post->create( 1329 array( 1330 'post_type' => 'attachment', 1331 'post_title' => 'Foo', 1332 'post_name' => "$p1-foo", 1333 ) 1334 ); 1137 1335 1138 1336 $this->go_to( get_permalink( $p2 ) ); … … 1146 1344 */ 1147 1345 public function test_is_author_should_not_match_numeric_id_to_nickname_beginning_with_id() { 1148 $u1 = self::factory()->user->create( array( 1149 'nickname' => 'Foo', 1150 'user_nicename' => 'foo', 1151 ) ); 1152 $u2 = self::factory()->user->create( array( 1153 'nickname' => "$u1 Foo", 1154 'user_nicename' => 'foo-2', 1155 ) ); 1346 $u1 = self::factory()->user->create( 1347 array( 1348 'nickname' => 'Foo', 1349 'user_nicename' => 'foo', 1350 ) 1351 ); 1352 $u2 = self::factory()->user->create( 1353 array( 1354 'nickname' => "$u1 Foo", 1355 'user_nicename' => 'foo-2', 1356 ) 1357 ); 1156 1358 1157 1359 $this->go_to( get_author_posts_url( $u2 ) ); … … 1165 1367 */ 1166 1368 public function test_is_author_should_not_match_numeric_id_to_user_nicename_beginning_with_id() { 1167 $u1 = self::factory()->user->create( array( 1168 'nickname' => 'Foo', 1169 'user_nicename' => 'foo', 1170 ) ); 1171 $u2 = self::factory()->user->create( array( 1172 'nickname' => 'Foo', 1173 'user_nicename' => "$u1-foo", 1174 ) ); 1369 $u1 = self::factory()->user->create( 1370 array( 1371 'nickname' => 'Foo', 1372 'user_nicename' => 'foo', 1373 ) 1374 ); 1375 $u2 = self::factory()->user->create( 1376 array( 1377 'nickname' => 'Foo', 1378 'user_nicename' => "$u1-foo", 1379 ) 1380 ); 1175 1381 1176 1382 $this->go_to( get_author_posts_url( $u2 ) ); … … 1184 1390 */ 1185 1391 public function test_is_category_should_not_match_numeric_id_to_name_beginning_with_id() { 1186 $t1 = self::factory()->term->create( array( 1187 'taxonomy' => 'category', 1188 'slug' => 'foo', 1189 'name' => 'foo', 1190 ) ); 1191 $t2 = self::factory()->term->create( array( 1192 'taxonomy' => 'category', 1193 'slug' => "$t1-foo", 1194 'name' => 'foo 2', 1195 ) ); 1392 $t1 = self::factory()->term->create( 1393 array( 1394 'taxonomy' => 'category', 1395 'slug' => 'foo', 1396 'name' => 'foo', 1397 ) 1398 ); 1399 $t2 = self::factory()->term->create( 1400 array( 1401 'taxonomy' => 'category', 1402 'slug' => "$t1-foo", 1403 'name' => 'foo 2', 1404 ) 1405 ); 1196 1406 1197 1407 $this->go_to( get_term_link( $t2 ) ); … … 1205 1415 */ 1206 1416 public function test_is_category_should_not_match_numeric_id_to_slug_beginning_with_id() { 1207 $t1 = self::factory()->term->create( array( 1208 'taxonomy' => 'category', 1209 'slug' => 'foo', 1210 'name' => 'foo', 1211 ) ); 1212 $t2 = self::factory()->term->create( array( 1213 'taxonomy' => 'category', 1214 'slug' => 'foo-2', 1215 'name' => "$t1 foo", 1216 ) ); 1417 $t1 = self::factory()->term->create( 1418 array( 1419 'taxonomy' => 'category', 1420 'slug' => 'foo', 1421 'name' => 'foo', 1422 ) 1423 ); 1424 $t2 = self::factory()->term->create( 1425 array( 1426 'taxonomy' => 'category', 1427 'slug' => 'foo-2', 1428 'name' => "$t1 foo", 1429 ) 1430 ); 1217 1431 1218 1432 $this->go_to( get_term_link( $t2 ) ); … … 1226 1440 */ 1227 1441 public function test_is_tag_should_not_match_numeric_id_to_name_beginning_with_id() { 1228 $t1 = self::factory()->term->create( array( 1229 'taxonomy' => 'post_tag', 1230 'slug' => 'foo', 1231 'name' => 'foo', 1232 ) ); 1233 $t2 = self::factory()->term->create( array( 1234 'taxonomy' => 'post_tag', 1235 'slug' => "$t1-foo", 1236 'name' => 'foo 2', 1237 ) ); 1442 $t1 = self::factory()->term->create( 1443 array( 1444 'taxonomy' => 'post_tag', 1445 'slug' => 'foo', 1446 'name' => 'foo', 1447 ) 1448 ); 1449 $t2 = self::factory()->term->create( 1450 array( 1451 'taxonomy' => 'post_tag', 1452 'slug' => "$t1-foo", 1453 'name' => 'foo 2', 1454 ) 1455 ); 1238 1456 1239 1457 $this->go_to( get_term_link( $t2 ) ); … … 1247 1465 */ 1248 1466 public function test_is_tag_should_not_match_numeric_id_to_slug_beginning_with_id() { 1249 $t1 = self::factory()->term->create( array( 1250 'taxonomy' => 'post_tag', 1251 'slug' => 'foo', 1252 'name' => 'foo', 1253 ) ); 1254 $t2 = self::factory()->term->create( array( 1255 'taxonomy' => 'post_tag', 1256 'slug' => 'foo-2', 1257 'name' => "$t1 foo", 1258 ) ); 1467 $t1 = self::factory()->term->create( 1468 array( 1469 'taxonomy' => 'post_tag', 1470 'slug' => 'foo', 1471 'name' => 'foo', 1472 ) 1473 ); 1474 $t2 = self::factory()->term->create( 1475 array( 1476 'taxonomy' => 'post_tag', 1477 'slug' => 'foo-2', 1478 'name' => "$t1 foo", 1479 ) 1480 ); 1259 1481 1260 1482 $this->go_to( get_term_link( $t2 ) ); … … 1268 1490 */ 1269 1491 public function test_is_page_should_not_match_numeric_id_to_post_title_beginning_with_id() { 1270 $p1 = self::factory()->post->create( array( 1271 'post_type' => 'page', 1272 'post_title' => 'Foo', 1273 'post_name' => 'foo', 1274 ) ); 1275 $p2 = self::factory()->post->create( array( 1276 'post_type' => 'page', 1277 'post_title' => "$p1 Foo", 1278 'post_name' => 'foo-2', 1279 ) ); 1492 $p1 = self::factory()->post->create( 1493 array( 1494 'post_type' => 'page', 1495 'post_title' => 'Foo', 1496 'post_name' => 'foo', 1497 ) 1498 ); 1499 $p2 = self::factory()->post->create( 1500 array( 1501 'post_type' => 'page', 1502 'post_title' => "$p1 Foo", 1503 'post_name' => 'foo-2', 1504 ) 1505 ); 1280 1506 1281 1507 $this->go_to( get_permalink( $p2 ) ); … … 1289 1515 */ 1290 1516 public function test_is_page_should_not_match_numeric_id_to_post_name_beginning_with_id() { 1291 $p1 = self::factory()->post->create( array( 1292 'post_type' => 'page', 1293 'post_title' => 'Foo', 1294 'post_name' => 'foo', 1295 ) ); 1296 $p2 = self::factory()->post->create( array( 1297 'post_type' => 'page', 1298 'post_title' => 'Foo', 1299 'post_name' => "$p1-foo", 1300 ) ); 1517 $p1 = self::factory()->post->create( 1518 array( 1519 'post_type' => 'page', 1520 'post_title' => 'Foo', 1521 'post_name' => 'foo', 1522 ) 1523 ); 1524 $p2 = self::factory()->post->create( 1525 array( 1526 'post_type' => 'page', 1527 'post_title' => 'Foo', 1528 'post_name' => "$p1-foo", 1529 ) 1530 ); 1301 1531 1302 1532 $this->go_to( get_permalink( $p2 ) ); … … 1310 1540 */ 1311 1541 public function test_is_single_should_not_match_numeric_id_to_post_title_beginning_with_id() { 1312 $p1 = self::factory()->post->create( array( 1313 'post_type' => 'post', 1314 'post_title' => 'Foo', 1315 'post_name' => 'foo', 1316 ) ); 1317 $p2 = self::factory()->post->create( array( 1318 'post_type' => 'post', 1319 'post_title' => "$p1 Foo", 1320 'post_name' => 'foo-2', 1321 ) ); 1542 $p1 = self::factory()->post->create( 1543 array( 1544 'post_type' => 'post', 1545 'post_title' => 'Foo', 1546 'post_name' => 'foo', 1547 ) 1548 ); 1549 $p2 = self::factory()->post->create( 1550 array( 1551 'post_type' => 'post', 1552 'post_title' => "$p1 Foo", 1553 'post_name' => 'foo-2', 1554 ) 1555 ); 1322 1556 1323 1557 $this->go_to( get_permalink( $p2 ) ); … … 1331 1565 */ 1332 1566 public function test_is_single_should_not_match_numeric_id_to_post_name_beginning_with_id() { 1333 $p1 = self::factory()->post->create( array( 1334 'post_type' => 'post', 1335 'post_title' => 'Foo', 1336 'post_name' => 'foo', 1337 ) ); 1338 $p2 = self::factory()->post->create( array( 1339 'post_type' => 'post', 1340 'post_title' => 'Foo', 1341 'post_name' => "$p1-foo", 1342 ) ); 1567 $p1 = self::factory()->post->create( 1568 array( 1569 'post_type' => 'post', 1570 'post_title' => 'Foo', 1571 'post_name' => 'foo', 1572 ) 1573 ); 1574 $p2 = self::factory()->post->create( 1575 array( 1576 'post_type' => 'post', 1577 'post_title' => 'Foo', 1578 'post_name' => "$p1-foo", 1579 ) 1580 ); 1343 1581 1344 1582 $this->go_to( get_permalink( $p2 ) );
Note: See TracChangeset
for help on using the changeset viewer.