Example #1
0
 /**
  * Sets some query var parameters on the comments query before comments are fetched.
  *
  * @param WP_Comment_Query $query
  * @return void
  */
 public function on_pre_get_comments(WP_Comment_Query $query)
 {
     if (!$this->context->is_comments_edit_screen()) {
         return;
     }
     $old = isset($query->query_vars['type__not_in']) ? (array) $query->query_vars['type__not_in'] : array();
     $query->query_vars['type__not_in'] = array_merge($old, (array) $this->comment_type);
 }
Example #2
0
 /**
  * @test
  * it should preserve existing type exclusions
  */
 public function it_should_preserve_existing_type_exclusions()
 {
     $this->context->is_comments_edit_screen()->willReturn(true);
     $sut = $this->make_instance();
     $query = $this->getMockBuilder('WP_Comment_Query')->disableOriginalConstructor()->getMock();
     $query->query_vars = [];
     $query->query_vars['type__not_in'] = ['some-other-type'];
     $sut->on_pre_get_comments($query);
     $this->assertEquals(array_merge(['some-other-type'], (array) $this->types), $query->query_vars['type__not_in']);
 }