woocommerce/tests/legacy/unit-tests/crud/query.php

39 lines
802 B
PHP
Raw Normal View History

2017-04-24 18:33:17 +00:00
<?php
/**
* WC_Object_Query tests
* @package WooCommerce\Tests\CRUD
2017-04-26 17:49:19 +00:00
* @since 3.1.0
2017-04-24 18:33:17 +00:00
*/
class WC_Tests_WC_Object_Query extends WC_Unit_Test_Case {
2017-04-26 17:49:19 +00:00
/**
* Test the default query var values.
*
* @since 3.1.0
*/
2017-04-24 18:33:17 +00:00
function test_default_query() {
$query = new WC_Mock_WC_Object_Query();
2017-04-27 21:46:00 +00:00
$this->assertNotEmpty( $query->get_query_vars() );
2017-04-24 23:28:13 +00:00
$this->assertEquals( '', $query->get( 'parent' ) );
2017-04-24 18:33:17 +00:00
$this->assertEquals( 'date', $query->get( 'orderby' ) );
}
2017-04-26 17:49:19 +00:00
/**
* Test setting/getting query vars.
*
* @since 3.1.0
*/
2017-04-24 18:33:17 +00:00
function test_query_with_args() {
$args = array(
2017-07-06 18:12:02 +00:00
'limit' => 15,
2017-04-24 18:33:17 +00:00
);
$query = new WC_Mock_WC_Object_Query( $args );
2017-04-27 21:46:00 +00:00
$this->assertEquals( 15, $query->get( 'limit' ) );
$query->set( 'limit', 20 );
$this->assertEquals( 20, $query->get( 'limit' ) );
2017-04-24 18:33:17 +00:00
}
}