Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit cddc80b

Browse files
author
mattallan
committed
Add unit tests to test quantities are handled properly
1 parent 9441a5c commit cddc80b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/test-wcs-order-functions.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,5 +400,26 @@ public function test_wcs_set_recurring_item_total() {
400400

401401
$this->assertEquals( 50, $line_item->get_total() );
402402
$this->assertEquals( 50, $line_item->get_subtotal() );
403+
404+
/**
405+
* Subscription item with quantity.
406+
*/
407+
$sign_up_fee_trial_product = WCS_Helper_Product::create_simple_subscription_product(
408+
[
409+
'price' => 40,
410+
'subscription_sign_up_fee' => 60,
411+
'subscription_trial_length' => 10,
412+
]
413+
);
414+
415+
$line_item->set_product( $sign_up_fee_trial_product );
416+
$line_item->set_quantity( 2 );
417+
$line_item->set_total( 120 ); // Initial total is just the sign-up fee.
418+
$line_item->set_subtotal( 120 );
419+
420+
wcs_set_recurring_item_total( $line_item );
421+
422+
$this->assertEquals( 80, $line_item->get_total() );
423+
$this->assertEquals( 80, $line_item->get_subtotal() );
403424
}
404425
}

0 commit comments

Comments
 (0)