Make WordPress Core


Ignore:
Timestamp:
01/19/2016 02:54:28 AM (9 years ago)
Author:
boonebgorges
Message:

Ignore false values of 'search' in WP_Comment_Query.

Props danielbachhuber.
Fixes #35513.

File:
1 edited

Legend:

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

    r36326 r36345  
    11801180    }
    11811181
     1182    /**
     1183     * @ticket 35513
     1184     */
     1185    public function test_search_false_should_be_ignored() {
     1186        $q = new WP_Comment_Query();
     1187        $q->query( array(
     1188            'search' => false,
     1189        ) );
     1190        $this->assertNotContains( "comment_author LIKE", $q->request );
     1191    }
     1192
     1193    /**
     1194     * @ticket 35513
     1195     */
     1196    public function test_search_null_should_be_ignored() {
     1197        $q = new WP_Comment_Query();
     1198        $q->query( array(
     1199            'search' => null,
     1200        ) );
     1201        $this->assertNotContains( "comment_author LIKE", $q->request );
     1202    }
     1203
     1204    /**
     1205     * @ticket 35513
     1206     */
     1207    public function test_search_empty_string_should_be_ignored() {
     1208        $q = new WP_Comment_Query();
     1209        $q->query( array(
     1210            'search' => false,
     1211        ) );
     1212        $this->assertNotContains( "comment_author LIKE", $q->request );
     1213    }
     1214
     1215    /**
     1216     * @ticket 35513
     1217     */
     1218    public function test_search_int_0_should_not_be_ignored() {
     1219        $q = new WP_Comment_Query();
     1220        $q->query( array(
     1221            'search' => 0,
     1222        ) );
     1223        $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1224    }
     1225
     1226    /**
     1227     * @ticket 35513
     1228     */
     1229    public function test_search_string_0_should_not_be_ignored() {
     1230        $q = new WP_Comment_Query();
     1231        $q->query( array(
     1232            'search' => '0',
     1233        ) );
     1234        $this->assertContains( "comment_author LIKE '%0%'", $q->request );
     1235    }
     1236
    11821237    public function test_orderby_default() {
    11831238        global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.