Skip to content

Instantly share code, notes, and snippets.

@justinshreve
Created September 27, 2016 17:51
Show Gist options
  • Save justinshreve/fcd7c0646b9149d3d5df5d2b94c995bc to your computer and use it in GitHub Desktop.
Save justinshreve/fcd7c0646b9149d3d5df5d2b94c995bc to your computer and use it in GitHub Desktop.
<?php
/**
* Legacy Customers API Tests
* @package WooCommerce\Tests\API
*/
class WC_Tests_API_Legacy_Customers extends WC_API_Unit_Test_Case {
/** @var WC_API_Customers instance */
protected $endpoint;
/**
* Setup test customer data.
*/
public function setUp() {
parent::setUp();
$this->endpoint = WC()->api->WC_API_Customers;
}
/**
* Test GET customers filtering
*/
public function test_filter_customer() {
global $wpdb;
wp_insert_user( array(
'user_email' => '[email protected]',
'user_login' => 'test_filter_customer_2',
'user_pass' => 'hunter2',
'user_registered' => '2016-01-01T12:12:12Z',
'role' => 'customer',
) );
wp_insert_user( array(
'user_email' => '[email protected]',
'user_login' => 'test_filter_customer_1',
'user_pass' => 'hunter2',
'user_registered' => '2016-01-03T12:12:12Z',
'role' => 'customer',
) );
$response = $this->endpoint->get_customers( null, array( 'created_at_min' => '2016-01-01 00:00:00', 'created_at_max' => '2016-01-01 23:59:59' ) );
$this->assertEquals( 1, count( $response) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment