Make WordPress Core

Ticket #23931: tests-comment-query.1.php

File tests-comment-query.1.php, 1.2 KB (added by westonruter, 11 years ago)

Update unit tests to always create comments with a valid comment_post_ID

Line 
1Index: tests/comment/query.php
2===================================================================
3--- tests/comment/query.php     (revision 1326)
4+++ tests/comment/query.php     (working copy)
5@@ -25,7 +25,8 @@
6         * @ticket 21101
7         */
8        function test_get_comment_comment_approved_1() {
9-               $comment_id = $this->factory->comment->create();
10+               $comment_args = array( 'comment_post_ID' => $this->factory->post->create() );
11+               $comment_id = $this->factory->comment->create( $comment_args );
12                $comments_approved_1 = get_comments( array( 'status' => 'approve' ) );
13 
14                $this->assertEquals( 1, count( $comments_approved_1 ) );
15@@ -80,9 +81,10 @@
16         * @ticket 21003
17         */
18        function test_orderby_meta() {
19-               $comment_id = $this->factory->comment->create();
20-               $comment_id2 = $this->factory->comment->create();
21-               $comment_id3 = $this->factory->comment->create();
22+               $comment_args = array( 'comment_post_ID' => $this->factory->post->create() );
23+               $comment_id = $this->factory->comment->create( $comment_args );
24+               $comment_id2 = $this->factory->comment->create( $comment_args );
25+               $comment_id3 = $this->factory->comment->create( $comment_args );
26 
27                add_comment_meta( $comment_id, 'key', 'value1', true );
28                add_comment_meta( $comment_id, 'key1', 'value1', true );