Changeset 47122 for trunk/tests/phpunit/tests/meta/query.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/meta/query.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/meta/query.php
r46586 r47122 46 46 $query = new WP_Meta_Query( 47 47 array( 48 'foo', // empty string49 5, // int48 'foo', // Empty string. 49 5, // int 50 50 false, // bool 51 51 array(), … … 77 77 $this->assertEquals( 1, substr_count( $sql['join'], 'INNER JOIN' ) ); 78 78 79 // also check mixing key and key => value79 // Also check mixing key and key => value. 80 80 81 81 $query = new WP_Meta_Query( … … 175 175 $query = new WP_Meta_Query(); 176 176 177 // just meta_value177 // Just meta_value. 178 178 $expected = array( 179 179 'relation' => 'OR', … … 189 189 $this->assertEquals( $expected, $query->queries ); 190 190 191 // meta_key & meta_value 191 // meta_key & meta_value. 192 192 $expected = array( 193 193 'relation' => 'OR', … … 205 205 $this->assertEquals( $expected, $query->queries ); 206 206 207 // meta_compare 207 // meta_compare. 208 208 $expected = array( 209 209 'relation' => 'OR', … … 563 563 'relation' => 'OR', 564 564 565 // Empty 'compare' 565 // Empty 'compare'. 566 566 array( 567 567 'key' => 'foo', 568 568 ), 569 569 570 // Non-empty 'compare' 570 // Non-empty 'compare'. 571 571 array( 572 572 'key' => 'bar', … … 574 574 ), 575 575 576 // NOT EXISTS 576 // NOT EXISTS. 577 577 array( 578 578 'key' => 'baz', … … 580 580 ), 581 581 582 // Has a value 582 // Has a value. 583 583 array( 584 584 'key' => 'barry', … … 586 586 ), 587 587 588 // Has no key 588 // Has no key. 589 589 array( 590 590 'value' => 'bar', … … 595 595 $sql = $query1->get_sql( 'post', $wpdb->posts, 'ID', $this ); 596 596 597 // 'foo' and 'bar' should be queried against the non-aliased table 597 // 'foo' and 'bar' should be queried against the non-aliased table. 598 598 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'foo'" ) ); 599 599 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'bar'" ) ); 600 600 601 // NOT EXISTS compare queries are not key-only so should not be non-aliased 601 // NOT EXISTS compare queries are not key-only so should not be non-aliased. 602 602 $this->assertSame( 0, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'baz'" ) ); 603 603 604 // 'AND' queries don't have key-only queries 604 // 'AND' queries don't have key-only queries. 605 605 $query2 = new WP_Meta_Query( 606 606 array( 607 607 'relation' => 'AND', 608 608 609 // Empty 'compare' 609 // Empty 'compare'. 610 610 array( 611 611 'key' => 'foo', 612 612 ), 613 613 614 // Non-empty 'compare' 614 // Non-empty 'compare'. 615 615 array( 616 616 'key' => 'bar', … … 622 622 $sql = $query2->get_sql( 'post', $wpdb->posts, 'ID', $this ); 623 623 624 // Only 'foo' should be queried against the non-aliased table 624 // Only 'foo' should be queried against the non-aliased table. 625 625 $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'foo'" ) ); 626 626 $this->assertSame( 0, substr_count( $sql['where'], "$wpdb->postmeta.meta_key = 'bar'" ) );
Note: See TracChangeset
for help on using the changeset viewer.