Changeset 48990 for trunk/tests/phpunit/tests/comment/query.php
- Timestamp:
- 09/17/2020 07:53:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/query.php
r48987 r48990 4917 4917 return array( 555 ); 4918 4918 } 4919 4920 /** 4921 * @ticket 50521 4922 */ 4923 public function test_comments_pre_query_filter_should_set_comments_property() { 4924 add_filter( 'comments_pre_query', array( __CLASS__, 'filter_comments_pre_query_and_set_comments' ), 10, 2 ); 4925 4926 $q = new WP_Comment_Query(); 4927 $results = $q->query( array() ); 4928 4929 remove_filter( 'comments_pre_query', array( __CLASS__, 'filter_comments_pre_query_and_set_comments' ), 10, 2 ); 4930 4931 // Make sure the comments property is the same as the results. 4932 $this->assertSame( $results, $q->comments ); 4933 4934 // Make sure the comment type is `foobar`. 4935 $this->assertSame( 'foobar', $q->comments[0]->comment_type ); 4936 } 4937 4938 public static function filter_comments_pre_query_and_set_comments( $comments, $query ) { 4939 $c = self::factory()->comment->create( 4940 array( 4941 'comment_type' => 'foobar', 4942 'comment_approved' => '1', 4943 ) 4944 ); 4945 4946 return array( get_comment( $c ) ); 4947 } 4919 4948 }
Note: See TracChangeset
for help on using the changeset viewer.