Changeset 42594
- Timestamp:
- 01/24/2018 08:51:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/query.php
r42585 r42594 644 644 } 645 645 646 public function set_found_posts_provider() { 647 // count return 0 for null, but 1 for other data you may not expect 648 return array( 649 array( null, 0 ), 650 array( '', 1 ), 651 array( "To life, to life, l'chaim", 1 ), 652 array( false, 1 ), 653 ); 654 } 655 646 656 /** 647 657 * @ticket 42860 648 */ 649 public function test_set_found_posts_fields_posts_is_string() { 658 * 659 * @dataProvider set_found_posts_provider 660 */ 661 public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) { 650 662 if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { 651 663 $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' ); … … 660 672 ); 661 673 662 $q->posts = "To life, to life, l'chaim";674 $q->posts = $posts; 663 675 664 676 $methd = new \ReflectionMethod( 'WP_Query', 'set_found_posts' ); … … 666 678 $methd->invoke( $q, array( 'no_found_rows' => false ), array() ); 667 679 668 $this->assertEquals( 1, $q->found_posts ); 669 } 670 671 /** 672 * @ticket 42860 673 */ 674 public function test_set_found_posts_fields_posts_is_null() { 675 if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { 676 $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' ); 677 return; 678 } 679 680 $q = new WP_Query( 681 array( 682 'post_type' => 'wptests_pt', 683 'posts_per_page' => 1, 684 ) 685 ); 686 687 $q->posts = null; 688 689 $methd = new \ReflectionMethod( 'WP_Query', 'set_found_posts' ); 690 $methd->setAccessible( true ); 691 $methd->invoke( $q, array( 'no_found_rows' => false ), array() ); 692 693 $this->assertEquals( 0, $q->found_posts ); 680 $this->assertEquals( $expected, $q->found_posts ); 694 681 } 695 682
Note: See TracChangeset
for help on using the changeset viewer.