From 7ae3adfb802629a4cf044dd4b354d468fd82d886 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 19 Jan 2016 03:02:42 +0000 Subject: [PATCH] Share post fixture in `WP_Comment_Query` tests. See #30017. git-svn-id: https://develop.svn.wordpress.org/trunk@36346 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment/query.php | 498 +++++++++++++------------- 1 file changed, 252 insertions(+), 246 deletions(-) diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 01702596f7..6de468e10b 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -6,21 +6,27 @@ * @group comment */ class Tests_Comment_Query extends WP_UnitTestCase { - protected $post_id; + protected static $post_id; protected $comment_id; + public static function wpSetUpBeforeClass( $factory ) { + self::$post_id = $factory->post->create(); + } + + public static function wpTearDownAfterClass() { + wp_delete_post( self::$post_id, true ); + } + function setUp() { parent::setUp(); - - $this->post_id = self::factory()->post->create(); } public function test_query() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -31,7 +37,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_post_id_0() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -46,11 +52,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_query_type_empty_string() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -65,11 +71,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_query_type_comment() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -81,10 +87,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_type_pingback() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -97,10 +103,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_query_type_trackback() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -116,11 +122,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * 'pings' is an alias for 'trackback' + 'pingback'. */ public function test_query_type_pings() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -136,12 +142,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comments_and_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -156,12 +162,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_not__in_array_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -176,12 +182,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type__in_array_and_not_type_array_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -197,12 +203,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_and_type__not_in_array_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -218,12 +224,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type__not_in_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -238,11 +244,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comments_and_pings() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -257,9 +263,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_comment_pings() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -274,9 +280,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pingback() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -291,9 +297,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_custom_pingpack() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -308,9 +314,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pings() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -325,10 +331,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_status_approved_array_comment_pings() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -344,9 +350,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_trackback() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -361,9 +367,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_custom_trackback() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -378,10 +384,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 12668 */ public function test_type_array_pings_approved() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -397,9 +403,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_empty_string() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'spam' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'spam' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -414,8 +420,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21101 */ public function test_status_hold() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -430,8 +436,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21101 */ public function test_status_approve() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -443,9 +449,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_custom() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo1' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -457,9 +463,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_all() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -471,9 +477,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_status_default_to_all() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -487,9 +493,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_comma_any() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -504,9 +510,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_comma_separated() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -521,9 +527,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29612 */ public function test_status_array() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => 'foo' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => 'foo' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '0' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -619,9 +625,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 21003 */ function test_orderby_meta() { - $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); - $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); - $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); + $comment_id2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); + $comment_id3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); add_comment_meta( $comment_id, 'key', 'value1', true ); add_comment_meta( $comment_id, 'key1', 'value1', true ); @@ -814,9 +820,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ function test_get_comments_by_user() { $users = self::factory()->user->create_many( 2 ); - self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); - self::factory()->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + self::factory()->comment->create( array( 'user_id' => $users[0], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); + self::factory()->comment->create( array( 'user_id' => $users[1], 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $comments = get_comments( array( 'user_id' => $users[0], @@ -845,9 +851,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 35377 */ public function test_get_comments_by_author_url() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar/baz' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar/baz' ) ); $comments = get_comments( array( 'author_url' => 'http://foo.bar', @@ -861,9 +867,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 28434 */ function test_fields_ids_query() { - $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); // Ensure we are dealing with integers, and not objects. $this->assertInternalType( 'integer', $comment_1 ); @@ -879,9 +885,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_comment__in() { - $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -895,9 +901,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 29189 */ function test_fields_comment__not_in() { - $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); $comment_ids = get_comments( array( 'fields' => 'ids', @@ -1041,9 +1047,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_status_all() { - $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $comment_1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $comment_2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $comment_3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); $comments_approved_1 = get_comments( array( 'status' => 'all' ) ); $comment_ids = get_comments( array( 'fields' => 'ids' ) ); @@ -1054,10 +1060,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1072,11 +1078,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id_array() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1091,11 +1097,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_user_id_comma_separated() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 1, 'comment_approved' => '0' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 6, 'comment_approved' => '0' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 8, 'comment_approved' => '0' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1110,10 +1116,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_author_email() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1128,11 +1134,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_mixed_array() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1147,11 +1153,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 19623 */ public function test_get_comments_with_include_unapproved_mixed_comma_separated() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '1', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'foo@example.com' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 0, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); $found = get_comments( array( 'fields' => 'ids', @@ -1163,12 +1169,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_search() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); - $c4 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); - $c5 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); - $c6 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'foo', 'comment_author_email' => 'bar@example.com' ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'foo@example.com' ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://foo.bar' ) ); + $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_author_IP' => 'foo.bar' ) ); + $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com', 'comment_content' => 'Nice foo comment' ) ); + $c6 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 4, 'comment_approved' => '0', 'comment_author' => 'bar', 'comment_author_email' => 'bar@example.com', 'comment_author_url' => 'http://example.com' ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1472,7 +1478,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_ASC() { $now = current_time( 'mysql', 1 ); $comments = self::factory()->comment->create_many( 5, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_date_gmt' => $now, ) ); @@ -1492,7 +1498,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_case_of_tie_DESC() { $now = current_time( 'mysql', 1 ); $comments = self::factory()->comment->create_many( 5, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_date_gmt' => $now, ) ); @@ -1524,8 +1530,8 @@ class Tests_Comment_Query extends WP_UnitTestCase { } public function test_count() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); $q = new WP_Comment_Query(); $found = $q->query( array( @@ -1539,9 +1545,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 23369 */ public function test_count_with_meta_query() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c2 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); - $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); + $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); + $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'user_id' => 7 ) ); add_comment_meta( $c1, 'foo', 'bar' ); add_comment_meta( $c3, 'foo', 'bar' ); @@ -1797,7 +1803,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_it_should_be_possible_to_modify_meta_query_using_pre_get_comments_action() { $comments = self::factory()->comment->create_many( 2, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, ) ); add_comment_meta( $comments[1], 'foo', 'bar' ); @@ -1805,7 +1811,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { add_action( 'pre_get_comments', array( $this, 'modify_meta_query' ) ); $q = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', ) ); @@ -1828,7 +1834,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_it_should_be_possible_to_modify_meta_params_using_pre_get_comments_action() { $comments = self::factory()->comment->create_many( 2, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, ) ); add_comment_meta( $comments[1], 'foo', 'bar' ); @@ -1836,7 +1842,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { add_action( 'pre_get_comments', array( $this, 'modify_meta_params' ) ); $q = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', ) ); @@ -1854,15 +1860,15 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__in() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $ids = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', 'parent__in' => array( $c1 ) ) ); @@ -1874,24 +1880,24 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__in_commas() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c3 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $c4 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c2, ) ); $ids = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', 'parent__in' => "$c1,$c2" ) ); @@ -1903,16 +1909,16 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__not_in() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $ids = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', 'parent__not_in' => array( $c1 ) ) ); @@ -1924,25 +1930,25 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 33882 */ public function test_parent__not_in_commas() { - $c1 = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); + $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c2, ) ); $ids = new WP_Comment_Query( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'fields' => 'ids', 'parent__not_in' => "$c1,$c2" ) ); @@ -1955,21 +1961,21 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_orderby_comment__in() { self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); $c3 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); @@ -1988,10 +1994,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_no_found_rows_should_default_to_true() { - $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'number' => 2, ) ); @@ -2003,10 +2009,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_should_respect_no_found_rows_true() { - $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'number' => 2, 'no_found_rows' => true, ) ); @@ -2019,10 +2025,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { * @ticket 8071 */ public function test_should_respect_no_found_rows_false() { - $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'number' => 2, 'no_found_rows' => false, ) ); @@ -2036,23 +2042,23 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_hierarchical_should_skip_child_comments_in_offset() { $top_level_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $child_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $top_level_comments = self::factory()->comment->create_many( 3, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'hierarchical' => 'flat', 'number' => 2, 'offset' => 1, @@ -2069,23 +2075,23 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_hierarchical_should_not_include_child_comments_in_number() { $top_level_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $child_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $top_level_comments = self::factory()->comment->create_many( 3, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'hierarchical' => 'flat', 'number' => 2, 'orderby' => 'comment_ID', @@ -2100,35 +2106,35 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_hierarchical_threaded() { $c1 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $c3 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c2, ) ); $c4 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $c5 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $c6 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c5, ) ); @@ -2140,7 +2146,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { ); $query_args = array_merge( $args, array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, ) ); $q = new WP_Comment_Query( $query_args ); @@ -2163,35 +2169,35 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_hierarchical_threaded_approved() { $c1 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $c2 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $c3 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '0', 'comment_parent' => $c2, ) ); $c4 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1, ) ); $c5 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c5, ) ); @@ -2204,7 +2210,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { ); $query_args = array_merge( $args, array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, ) ); $q = new WP_Comment_Query( $query_args ); @@ -2224,24 +2230,24 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_comment_clauses_prepend_callback_should_be_respected_when_filling_descendants() { $top_level_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $child1_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $child2_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $top_level_comments = self::factory()->comment->create_many( 3, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); @@ -2249,7 +2255,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { add_filter( 'comments_clauses', array( $this, 'prepend_exclusions' ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'hierarchical' => 'flat', ) ); remove_filter( 'comments_clauses', array( $this, 'prepend_exclusions' ) ); @@ -2270,24 +2276,24 @@ class Tests_Comment_Query extends WP_UnitTestCase { */ public function test_comment_clauses_append_callback_should_be_respected_when_filling_descendants() { $top_level_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); $child1_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $child2_of_0 = self::factory()->comment->create( array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $top_level_0, ) ); $top_level_comments = self::factory()->comment->create_many( 3, array( - 'comment_post_ID' => $this->post_id, + 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', ) ); @@ -2295,7 +2301,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { add_filter( 'comments_clauses', array( $this, 'append_exclusions' ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'hierarchical' => 'flat', ) ); remove_filter( 'comments_clauses', array( $this, 'append_exclusions' ) ); @@ -2353,12 +2359,12 @@ class Tests_Comment_Query extends WP_UnitTestCase { public function test_comment_objects_should_be_filled_from_cache() { global $wpdb; - $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => $this->post_id ) ); + $comments = self::factory()->comment->create_many( 3, array( 'comment_post_ID' => self::$post_id ) ); clean_comment_cache( $comments ); $num_queries = $wpdb->num_queries; $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, 'no_found_rows' => true, 'update_comment_post_cache' => false, 'update_comment_meta_cache' => false, @@ -2380,10 +2386,10 @@ class Tests_Comment_Query extends WP_UnitTestCase { $suspend = wp_suspend_cache_addition(); wp_suspend_cache_addition( true ); - $c = self::factory()->comment->create( array( 'comment_post_ID' => $this->post_id ) ); + $c = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id ) ); $q = new WP_Comment_Query( array( - 'post_id' => $this->post_id, + 'post_id' => self::$post_id, ) ); wp_suspend_cache_addition( $suspend );