Make WordPress Core

Changeset 29982


Ignore:
Timestamp:
10/21/2014 02:17:25 PM (10 years ago)
Author:
boonebgorges
Message:

Add unit test for WP_Comment_Query 'search' param.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/query.php

    r29981 r29982  
    500500        $this->assertEqualSets( array( $c1, $c2, $c3, $c5 ), $found );
    501501    }
     502
     503    public function test_search() {
     504        $c1 = $this->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' ) );
     505        $c2 = $this->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' ) );
     506        $c3 = $this->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' ) );
     507        $c4 = $this->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' ) );
     508        $c5 = $this->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' ) );
     509        $c6 = $this->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' ) );
     510
     511        $q = new WP_Comment_Query();
     512        $found = $q->query( array(
     513            'search' => 'foo',
     514            'fields' => 'ids',
     515        ) );
     516
     517        $this->assertEquals( array( $c1, $c2, $c3, $c4, $c5 ), $found );
     518    }
    502519}
Note: See TracChangeset for help on using the changeset viewer.