Update batch test function names and constants

This commit is contained in:
Joshua Flowers 2019-04-15 16:33:03 +08:00 committed by Jeff Stieler
parent 591c66995d
commit 63c59a1f72
3 changed files with 12 additions and 12 deletions

View File

@ -72,13 +72,13 @@ class WC_Tests_API_Init extends WC_REST_Unit_Test_Case {
add_filter( 'query', array( $this, 'filter_order_query' ) ); add_filter( 'query', array( $this, 'filter_order_query' ) );
// Initiate sync. // Initiate sync.
WC_Admin_Reports_Sync::orders_lookup_process_order( $order->get_id() ); WC_Admin_Reports_Sync::orders_lookup_import_order( $order->get_id() );
// Verify that a retry job was scheduled. // Verify that a retry job was scheduled.
$this->assertCount( 1, $this->queue->actions ); $this->assertCount( 1, $this->queue->actions );
$this->assertArraySubset( $this->assertArraySubset(
array( array(
'hook' => WC_Admin_Reports_Sync::SINGLE_ORDER_ACTION, 'hook' => WC_Admin_Reports_Sync::SINGLE_ORDER_IMPORT_ACTION,
'args' => array( $order->get_id() ), 'args' => array( $order->get_id() ),
), ),
$this->queue->actions[0] $this->queue->actions[0]

View File

@ -45,7 +45,7 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
switch ( $action ) { switch ( $action ) {
case WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION: case WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION:
return $this->queue_batch_size; return $this->queue_batch_size;
case WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION: case WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION:
return $this->customers_batch_size; return $this->customers_batch_size;
case WC_Admin_Reports_Sync::ORDERS_BATCH_ACTION: case WC_Admin_Reports_Sync::ORDERS_BATCH_ACTION:
return $this->orders_batch_size; return $this->orders_batch_size;
@ -81,20 +81,20 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
$num_customers = 1234; // 1234 / 5 = 247 batches $num_customers = 1234; // 1234 / 5 = 247 batches
$num_batches = ceil( $num_customers / $this->customers_batch_size ); $num_batches = ceil( $num_customers / $this->customers_batch_size );
WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION ); WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION );
$this->assertCount( $this->queue_batch_size, $this->queue->actions ); $this->assertCount( $this->queue_batch_size, $this->queue->actions );
$this->assertArraySubset( $this->assertArraySubset(
array( array(
'hook' => WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION, 'hook' => WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION,
'args' => array( 1, 25, WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION ), 'args' => array( 1, 25, WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION ),
), ),
$this->queue->actions[0] $this->queue->actions[0]
); );
$this->assertArraySubset( $this->assertArraySubset(
array( array(
'hook' => WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION, 'hook' => WC_Admin_Reports_Sync::QUEUE_BATCH_ACTION,
'args' => array( 226, 247, WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION ), 'args' => array( 226, 247, WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION ),
), ),
$this->queue->actions[ $this->queue_batch_size - 1 ] $this->queue->actions[ $this->queue_batch_size - 1 ]
); );
@ -107,19 +107,19 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
$num_customers = 45; // 45 / 5 = 9 batches (which is less than the batch queue size) $num_customers = 45; // 45 / 5 = 9 batches (which is less than the batch queue size)
$num_batches = ceil( $num_customers / $this->customers_batch_size ); $num_batches = ceil( $num_customers / $this->customers_batch_size );
WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION ); WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION );
$this->assertCount( 9, $this->queue->actions ); $this->assertCount( 9, $this->queue->actions );
$this->assertArraySubset( $this->assertArraySubset(
array( array(
'hook' => WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION, 'hook' => WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION,
'args' => array( 1 ), 'args' => array( 1 ),
), ),
$this->queue->actions[0] $this->queue->actions[0]
); );
$this->assertArraySubset( $this->assertArraySubset(
array( array(
'hook' => WC_Admin_Reports_Sync::CUSTOMERS_BATCH_ACTION, 'hook' => WC_Admin_Reports_Sync::CUSTOMERS_IMPORT_BATCH_ACTION,
'args' => array( 9 ), 'args' => array( 9 ),
), ),
$this->queue->actions[8] $this->queue->actions[8]

View File

@ -37,13 +37,13 @@ class WC_Tests_Reports_Queue_Prioritization extends WC_REST_Unit_Test_Case {
* Test that we're setting a priority on our actions. * Test that we're setting a priority on our actions.
*/ */
public function test_queue_action_sets_priority() { public function test_queue_action_sets_priority() {
WC_Admin_Reports_Sync::queue()->schedule_single( time(), WC_Admin_Reports_Sync::SINGLE_ORDER_ACTION ); WC_Admin_Reports_Sync::queue()->schedule_single( time(), WC_Admin_Reports_Sync::SINGLE_ORDER_IMPORT_ACTION );
$actions = WC_Admin_Reports_Sync::queue()->search( $actions = WC_Admin_Reports_Sync::queue()->search(
array( array(
'status' => 'pending', 'status' => 'pending',
'claimed' => false, 'claimed' => false,
'hook' => WC_Admin_Reports_Sync::SINGLE_ORDER_ACTION, 'hook' => WC_Admin_Reports_Sync::SINGLE_ORDER_IMPORT_ACTION,
) )
); );
@ -55,7 +55,7 @@ class WC_Tests_Reports_Queue_Prioritization extends WC_REST_Unit_Test_Case {
$this->assertEquals( WC_Admin_ActionScheduler_wpPostStore::JOB_PRIORITY, $action->menu_order ); $this->assertEquals( WC_Admin_ActionScheduler_wpPostStore::JOB_PRIORITY, $action->menu_order );
WC_Admin_Reports_Sync::queue()->cancel_all( WC_Admin_Reports_Sync::SINGLE_ORDER_ACTION ); WC_Admin_Reports_Sync::queue()->cancel_all( WC_Admin_Reports_Sync::SINGLE_ORDER_IMPORT_ACTION );
} }
} }