Changeset 42343 for trunk/tests/phpunit/tests/admin/includesPost.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesPost.php
r41187 r42343 27 27 28 28 // Create New Draft Post 29 $_post_data = array();29 $_post_data = array(); 30 30 $_post_data['post_author'] = self::$contributor_id; 31 $_post_data['post_type'] = 'post';31 $_post_data['post_type'] = 'post'; 32 32 $_post_data['saveasdraft'] = true; 33 33 … … 38 38 39 39 // Submit Post for Approval 40 $_post_data = array();40 $_post_data = array(); 41 41 $_post_data['post_author'] = self::$contributor_id; 42 $_post_data['post_type'] = 'post';43 $_post_data['publish'] = true;42 $_post_data['post_type'] = 'post'; 43 $_post_data['publish'] = true; 44 44 45 45 $_results = _wp_translate_postdata( false, $_post_data ); … … 49 49 50 50 // Create New Draft Post for another user 51 $_post_data = array();51 $_post_data = array(); 52 52 $_post_data['post_author'] = self::$editor_id; 53 $_post_data['post_type'] = 'post';53 $_post_data['post_type'] = 'post'; 54 54 $_post_data['saveasdraft'] = true; 55 55 … … 60 60 61 61 // Edit Draft Post for another user 62 $_post_data = array();63 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );62 $_post_data = array(); 63 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$editor_id ) ); 64 64 $_post_data['post_author'] = self::$editor_id; 65 $_post_data['post_type'] = 'post';65 $_post_data['post_type'] = 'post'; 66 66 $_post_data['post_status'] = 'draft'; 67 67 $_post_data['saveasdraft'] = true; … … 77 77 78 78 // Create New Draft Post 79 $_post_data = array();79 $_post_data = array(); 80 80 $_post_data['post_author'] = self::$editor_id; 81 $_post_data['post_type'] = 'post';81 $_post_data['post_type'] = 'post'; 82 82 $_post_data['saveasdraft'] = true; 83 83 … … 88 88 89 89 // Publish Post 90 $_post_data = array();90 $_post_data = array(); 91 91 $_post_data['post_author'] = self::$editor_id; 92 $_post_data['post_type'] = 'post';93 $_post_data['publish'] = true;92 $_post_data['post_type'] = 'post'; 93 $_post_data['publish'] = true; 94 94 95 95 $_results = _wp_translate_postdata( false, $_post_data ); … … 99 99 100 100 // Create New Draft Post for another user 101 $_post_data = array();101 $_post_data = array(); 102 102 $_post_data['post_author'] = self::$contributor_id; 103 $_post_data['post_type'] = 'post';103 $_post_data['post_type'] = 'post'; 104 104 $_post_data['saveasdraft'] = true; 105 105 … … 110 110 111 111 // Edit Draft Post for another user 112 $_post_data = array();113 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$contributor_id ) );112 $_post_data = array(); 113 $_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$contributor_id ) ); 114 114 $_post_data['post_author'] = self::$contributor_id; 115 $_post_data['post_type'] = 'post';115 $_post_data['post_type'] = 'post'; 116 116 $_post_data['post_status'] = 'draft'; 117 117 $_post_data['saveasdraft'] = true; … … 134 134 $post_data = array( 135 135 'post_title' => 'Post title', 136 'content' => 'Post content',137 'post_type' => 'post',138 'post_ID' => $post->ID,136 'content' => 'Post content', 137 'post_type' => 'post', 138 'post_ID' => $post->ID, 139 139 ); 140 140 edit_post( $post_data ); … … 149 149 150 150 register_taxonomy( 'wptests_tax', array( 'post' ) ); 151 $t1 = self::factory()->term->create( array( 152 'taxonomy' => 'wptests_tax', 153 'name' => 'foo', 154 'slug' => 'bar', 155 ) ); 156 $t2 = self::factory()->term->create( array( 157 'taxonomy' => 'wptests_tax', 158 'name' => 'bar', 159 'slug' => 'foo', 160 ) ); 151 $t1 = self::factory()->term->create( 152 array( 153 'taxonomy' => 'wptests_tax', 154 'name' => 'foo', 155 'slug' => 'bar', 156 ) 157 ); 158 $t2 = self::factory()->term->create( 159 array( 160 'taxonomy' => 'wptests_tax', 161 'name' => 'bar', 162 'slug' => 'foo', 163 ) 164 ); 161 165 162 166 $post_data = array( 163 'post_ID' => self::$post_id,167 'post_ID' => self::$post_id, 164 168 'tax_input' => array( 165 169 'wptests_tax' => 'foo,baz', … … 185 189 186 190 register_taxonomy( 'wptests_tax', array( 'post' ) ); 187 self::factory()->term->create( array( 188 'taxonomy' => 'wptests_tax', 189 'name' => 'foo', 190 'slug' => 'bar', 191 ) ); 191 self::factory()->term->create( 192 array( 193 'taxonomy' => 'wptests_tax', 194 'name' => 'foo', 195 'slug' => 'bar', 196 ) 197 ); 192 198 193 199 $post_data = array( 194 'post_ID' => self::$post_id,200 'post_ID' => self::$post_id, 195 201 'tax_input' => array( 196 202 'wptests_tax' => ' ', … … 211 217 wp_set_current_user( self::$admin_id ); 212 218 213 $post1 = self::factory()->post->create( array( 214 'post_author' => self::$author_ids[0], 215 'comment_status' => 'open', 216 'ping_status' => 'open', 217 'post_status' => 'publish', 218 ) ); 219 220 $post2 = self::factory()->post->create( array( 221 'post_author' => self::$author_ids[1], 222 'comment_status' => 'closed', 223 'ping_status' => 'closed', 224 'post_status' => 'draft', 225 ) ); 219 $post1 = self::factory()->post->create( 220 array( 221 'post_author' => self::$author_ids[0], 222 'comment_status' => 'open', 223 'ping_status' => 'open', 224 'post_status' => 'publish', 225 ) 226 ); 227 228 $post2 = self::factory()->post->create( 229 array( 230 'post_author' => self::$author_ids[1], 231 'comment_status' => 'closed', 232 'ping_status' => 'closed', 233 'post_status' => 'draft', 234 ) 235 ); 226 236 227 237 $request = array( 228 'post_type' 229 'post_author' 230 'ping_status' 231 'comment_status' 232 '_status' 233 'post' 238 'post_type' => 'post', 239 'post_author' => -1, 240 'ping_status' => -1, 241 'comment_status' => -1, 242 '_status' => -1, 243 'post' => array( $post1, $post2 ), 234 244 ); 235 245 … … 312 322 313 323 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 314 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); 315 316 $found = get_sample_permalink( $p ); 324 $p = self::factory()->post->create( 325 array( 326 'post_status' => 'future', 327 'post_name' => 'foo', 328 'post_date' => $future_date, 329 ) 330 ); 331 332 $found = get_sample_permalink( $p ); 317 333 $expected = trailingslashit( home_url( $permalink_structure ) ); 318 334 … … 328 344 329 345 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 330 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) ); 346 $p = self::factory()->post->create( 347 array( 348 'post_status' => 'future', 349 'post_name' => 'foo', 350 'post_date' => $future_date, 351 ) 352 ); 331 353 332 354 $found = get_sample_permalink_html( $p ); … … 345 367 346 368 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 347 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo-صورة', 'post_date' => $future_date ) ); 369 $p = self::factory()->post->create( 370 array( 371 'post_status' => 'future', 372 'post_name' => 'foo-صورة', 373 'post_date' => $future_date, 374 ) 375 ); 348 376 349 377 $found = get_sample_permalink_html( $p ); 350 $post = get_post( $p );351 $this->assertContains( 'href="' . get_option( 'home' ) . "/". $post->post_name . '/"', $found );378 $post = get_post( $p ); 379 $this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found ); 352 380 $this->assertContains( '>' . urldecode( $post->post_name ) . '<', $found ); 353 381 } … … 361 389 wp_set_current_user( self::$admin_id ); 362 390 363 $p = self::factory()->attachment->create_object( 'صورة.jpg', 0, array( 364 'post_mime_type' => 'image/jpeg', 365 'post_type' => 'attachment', 366 'post_title' => 'صورة', 367 'post_status' => 'inherit', 368 ) ); 391 $p = self::factory()->attachment->create_object( 392 'صورة.jpg', 0, array( 393 'post_mime_type' => 'image/jpeg', 394 'post_type' => 'attachment', 395 'post_title' => 'صورة', 396 'post_status' => 'inherit', 397 ) 398 ); 369 399 370 400 $found = get_sample_permalink_html( $p ); 371 $post = get_post( $p );372 $this->assertContains( 'href="' . get_option( 'home' ) . "/". $post->post_name . '/"', $found );401 $post = get_post( $p ); 402 $this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found ); 373 403 $this->assertContains( '>' . urldecode( get_permalink( $post ) ) . '<', $found ); 374 404 } … … 384 414 385 415 // Published posts should use published permalink 386 $p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo-صورة' ) ); 387 388 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 389 $post = get_post( $p ); 416 $p = self::factory()->post->create( 417 array( 418 'post_status' => 'publish', 419 'post_name' => 'foo-صورة', 420 ) 421 ); 422 423 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 424 $post = get_post( $p ); 390 425 $message = 'Published post'; 391 $this->assertContains( 'href="' . get_option( 'home' ) . "/". $post->post_name . '/"', $found, $message );426 $this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found, $message ); 392 427 $this->assertContains( '>new_slug-صورة<', $found, $message ); 393 428 394 429 // Scheduled posts should use published permalink 395 430 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 396 $p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'bar-صورة', 'post_date' => $future_date ) ); 397 398 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 399 $post = get_post( $p ); 431 $p = self::factory()->post->create( 432 array( 433 'post_status' => 'future', 434 'post_name' => 'bar-صورة', 435 'post_date' => $future_date, 436 ) 437 ); 438 439 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 440 $post = get_post( $p ); 400 441 $message = 'Scheduled post'; 401 $this->assertContains( 'href="' . get_option( 'home' ) . "/". $post->post_name . '/"', $found, $message );442 $this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found, $message ); 402 443 $this->assertContains( '>new_slug-صورة<', $found, $message ); 403 444 404 445 // Draft posts should use preview link 405 $p = self::factory()->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz-صورة' ) ); 406 407 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 408 $post = get_post( $p ); 446 $p = self::factory()->post->create( 447 array( 448 'post_status' => 'draft', 449 'post_name' => 'baz-صورة', 450 ) 451 ); 452 453 $found = get_sample_permalink_html( $p, null, 'new_slug-صورة' ); 454 $post = get_post( $p ); 409 455 $message = 'Draft post'; 410 456 … … 426 472 427 473 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 428 $p = self::factory()->post->create( array( 'post_status' => 'pending', 'post_name' => '', 'post_date' => $future_date ) ); 474 $p = self::factory()->post->create( 475 array( 476 'post_status' => 'pending', 477 'post_name' => '', 478 'post_date' => $future_date, 479 ) 480 ); 429 481 430 482 $found = get_sample_permalink_html( $p ); 431 $post = get_post( $p );483 $post = get_post( $p ); 432 484 $this->assertContains( 'href="' . esc_url( get_preview_post_link( $post ) ), $found ); 433 485 } … … 439 491 $this->set_permalink_structure( '/%postname%/' ); 440 492 441 $p = self::factory()->post->create( array( 442 'post_name' => '2015', 443 ) ); 493 $p = self::factory()->post->create( 494 array( 495 'post_name' => '2015', 496 ) 497 ); 444 498 445 499 $found = get_sample_permalink( $p ); … … 453 507 $this->set_permalink_structure( '/%year%/%postname%/' ); 454 508 455 $p = self::factory()->post->create( array( 456 'post_name' => '2015', 457 ) ); 509 $p = self::factory()->post->create( 510 array( 511 'post_name' => '2015', 512 ) 513 ); 458 514 459 515 $found = get_sample_permalink( $p ); … … 467 523 $this->set_permalink_structure( '/%year%/%postname%/' ); 468 524 469 $p = self::factory()->post->create( array( 470 'post_name' => '11', 471 ) ); 525 $p = self::factory()->post->create( 526 array( 527 'post_name' => '11', 528 ) 529 ); 472 530 473 531 $found = get_sample_permalink( $p ); … … 481 539 $this->set_permalink_structure( '/%year%/%postname%/' ); 482 540 483 $p = self::factory()->post->create( array( 484 'post_name' => '13', 485 ) ); 541 $p = self::factory()->post->create( 542 array( 543 'post_name' => '13', 544 ) 545 ); 486 546 487 547 $found = get_sample_permalink( $p ); … … 495 555 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 496 556 497 $p = self::factory()->post->create( array( 498 'post_name' => '30', 499 ) ); 557 $p = self::factory()->post->create( 558 array( 559 'post_name' => '30', 560 ) 561 ); 500 562 501 563 $found = get_sample_permalink( $p ); … … 509 571 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 510 572 511 self::factory()->post->create( array( 512 'post_name' => '30-2', 513 ) ); 514 515 $p = self::factory()->post->create( array( 516 'post_name' => '30', 517 ) ); 573 self::factory()->post->create( 574 array( 575 'post_name' => '30-2', 576 ) 577 ); 578 579 $p = self::factory()->post->create( 580 array( 581 'post_name' => '30', 582 ) 583 ); 518 584 519 585 $found = get_sample_permalink( $p ); … … 527 593 $this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); 528 594 529 $p = self::factory()->post->create( array( 530 'post_name' => '32', 531 ) ); 595 $p = self::factory()->post->create( 596 array( 597 'post_name' => '32', 598 ) 599 ); 532 600 533 601 $found = get_sample_permalink( $p ); … … 541 609 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); 542 610 543 $p = self::factory()->post->create( array( 544 'post_name' => '30', 545 ) ); 611 $p = self::factory()->post->create( 612 array( 613 'post_name' => '30', 614 ) 615 ); 546 616 547 617 $found = get_sample_permalink( $p ); … … 555 625 $this->set_permalink_structure( '/%postname%/' ); 556 626 557 $parent = self::factory()->post->create( array( 558 'post_type' => 'page', 559 'post_title' => 'Parent Page', 560 ) ); 561 562 $child = self::factory()->post->create( array( 563 'post_type' => 'page', 564 'post_title' => 'Child Page', 565 'post_parent' => $parent, 566 'post_status' => 'draft', 567 ) ); 627 $parent = self::factory()->post->create( 628 array( 629 'post_type' => 'page', 630 'post_title' => 'Parent Page', 631 ) 632 ); 633 634 $child = self::factory()->post->create( 635 array( 636 'post_type' => 'page', 637 'post_title' => 'Child Page', 638 'post_parent' => $parent, 639 'post_status' => 'draft', 640 ) 641 ); 568 642 569 643 $actual = get_sample_permalink( $child ); … … 573 647 574 648 public function test_post_exists_should_match_title() { 575 $p = self::factory()->post->create( array( 576 'post_title' => 'Foo Bar', 577 ) ); 649 $p = self::factory()->post->create( 650 array( 651 'post_title' => 'Foo Bar', 652 ) 653 ); 578 654 579 655 $this->assertSame( $p, post_exists( 'Foo Bar' ) ); … … 581 657 582 658 public function test_post_exists_should_not_match_nonexistent_title() { 583 $p = self::factory()->post->create( array( 584 'post_title' => 'Foo Bar', 585 ) ); 659 $p = self::factory()->post->create( 660 array( 661 'post_title' => 'Foo Bar', 662 ) 663 ); 586 664 587 665 $this->assertSame( 0, post_exists( 'Foo Bar Baz' ) ); … … 589 667 590 668 public function test_post_exists_should_match_nonempty_content() { 591 $title = 'Foo Bar';669 $title = 'Foo Bar'; 592 670 $content = 'Foo Bar Baz'; 593 $p = self::factory()->post->create( array( 594 'post_title' => $title, 595 'post_content' => $content, 596 ) ); 671 $p = self::factory()->post->create( 672 array( 673 'post_title' => $title, 674 'post_content' => $content, 675 ) 676 ); 597 677 598 678 $this->assertSame( $p, post_exists( $title, $content ) ); … … 603 683 */ 604 684 public function test_post_exists_should_match_content_with_no_title() { 605 $title = '';685 $title = ''; 606 686 $content = 'Foo Bar Baz'; 607 $p = self::factory()->post->create( array( 608 'post_title' => $title, 609 'post_content' => $content, 610 ) ); 687 $p = self::factory()->post->create( 688 array( 689 'post_title' => $title, 690 'post_content' => $content, 691 ) 692 ); 611 693 612 694 $this->assertSame( $p, post_exists( $title, $content ) ); … … 614 696 615 697 public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() { 616 $title = 'Foo Bar';698 $title = 'Foo Bar'; 617 699 $content = 'Foo Bar Baz'; 618 $p = self::factory()->post->create( array( 619 'post_title' => $title, 620 'post_content' => $content . ' Quz', 621 ) ); 700 $p = self::factory()->post->create( 701 array( 702 'post_title' => $title, 703 'post_content' => $content . ' Quz', 704 ) 705 ); 622 706 623 707 $this->assertSame( 0, post_exists( $title, $content ) ); … … 626 710 public function test_post_exists_should_match_nonempty_date() { 627 711 $title = 'Foo Bar'; 628 $date = '2014-05-08 12:00:00'; 629 $p = self::factory()->post->create( array( 630 'post_title' => $title, 631 'post_date' => $date, 632 ) ); 712 $date = '2014-05-08 12:00:00'; 713 $p = self::factory()->post->create( 714 array( 715 'post_title' => $title, 716 'post_date' => $date, 717 ) 718 ); 633 719 634 720 $this->assertSame( $p, post_exists( $title, '', $date ) ); … … 637 723 public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() { 638 724 $title = 'Foo Bar'; 639 $date = '2014-05-08 12:00:00'; 640 $p = self::factory()->post->create( array( 641 'post_title' => $title, 642 'post_date' => '2015-10-10 00:00:00', 643 ) ); 725 $date = '2014-05-08 12:00:00'; 726 $p = self::factory()->post->create( 727 array( 728 'post_title' => $title, 729 'post_date' => '2015-10-10 00:00:00', 730 ) 731 ); 644 732 645 733 $this->assertSame( 0, post_exists( $title, '', $date ) ); … … 647 735 648 736 public function test_post_exists_should_match_nonempty_title_content_and_date() { 649 $title = 'Foo Bar';737 $title = 'Foo Bar'; 650 738 $content = 'Foo Bar Baz'; 651 $date = '2014-05-08 12:00:00'; 652 $p = self::factory()->post->create( array( 653 'post_title' => $title, 654 'post_content' => $content, 655 'post_date' => $date, 656 ) ); 739 $date = '2014-05-08 12:00:00'; 740 $p = self::factory()->post->create( 741 array( 742 'post_title' => $title, 743 'post_content' => $content, 744 'post_date' => $date, 745 ) 746 ); 657 747 658 748 $this->assertSame( $p, post_exists( $title, $content, $date ) );
Note: See TracChangeset
for help on using the changeset viewer.