36 lines
923 B
PHP
36 lines
923 B
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Tests for WC_Query.
|
||
|
*/
|
||
|
class WC_Query_Test extends \WC_Unit_Test_Case {
|
||
|
|
||
|
/**
|
||
|
* @testdox 'price_filter_post_clauses' generates the proper 'where' clause when there are 'max_price' and 'min_price' arguments in the query.
|
||
|
*/
|
||
|
public function test_price_filter_post_clauses_creates_the_proper_where_clause() {
|
||
|
// phpcs:disable Squiz.Commenting
|
||
|
$wp_query = new class() {
|
||
|
public function is_main_query() {
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
// phpcs:enable Squiz.Commenting
|
||
|
|
||
|
$_GET['min_price'] = '100';
|
||
|
$_GET['max_price'] = '200';
|
||
|
|
||
|
$sut = new WC_Query();
|
||
|
|
||
|
$args = array(
|
||
|
'join' => '(JOIN CLAUSE)',
|
||
|
'where' => '(WHERE CLAUSE)',
|
||
|
);
|
||
|
|
||
|
$args = $sut->price_filter_post_clauses( $args, $wp_query );
|
||
|
$expected = '(WHERE CLAUSE) AND NOT (200.000000<wc_product_meta_lookup.min_price OR 100.000000>wc_product_meta_lookup.max_price ) ';
|
||
|
|
||
|
$this->assertEquals( $expected, $args['where'] );
|
||
|
}
|
||
|
}
|