Better docs for test functions to specify expectations.
This commit is contained in:
parent
b4b03f3b46
commit
5171108967
|
@ -38,9 +38,9 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
/**
|
||||
* Helper function to simulate creating order from cart.
|
||||
*
|
||||
* @param string $status_from Status for the newly created order.
|
||||
* @param string $status Status for the newly created order.
|
||||
*/
|
||||
private function create_order_from_cart_with_status( $status_from ) {
|
||||
private function create_order_from_cart_with_status( $status ) {
|
||||
$product = WC_Helper_Product::create_simple_product(
|
||||
true,
|
||||
array(
|
||||
|
@ -55,7 +55,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
$checkout = WC_Checkout::instance();
|
||||
$order = new WC_Order();
|
||||
$checkout->set_data_from_cart( $order );
|
||||
$order->set_status( $status_from );
|
||||
$order->set_status( $status );
|
||||
$order->save();
|
||||
return $order;
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which reduces stock to another status which also reduces stock.
|
||||
* Stock should have reduced once already, and should not reduce again.
|
||||
*/
|
||||
public function test_status_transition_stock_reduce_to_stock_reduce() {
|
||||
foreach ( $this->order_stock_reduce_statuses as $order_status_from ) {
|
||||
|
@ -97,6 +98,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which reduces stock to another status which restores stock.
|
||||
* Should should have already reduced once, and will increase again after transitioning.
|
||||
*/
|
||||
public function test_status_transition_stock_reduce_to_stock_restore() {
|
||||
foreach ( $this->order_stock_reduce_statuses as $order_status_from ) {
|
||||
|
@ -108,6 +110,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which reduces stock to another status which don't affect inventory.
|
||||
* Stock should have already reduced, and will not change on transitioning.
|
||||
*/
|
||||
public function test_status_transition_stock_reduce_to_stock_no_effect() {
|
||||
foreach ( $this->order_stock_reduce_statuses as $order_status_from ) {
|
||||
|
@ -119,6 +122,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which restores stock to another status which reduces stock.
|
||||
* Stock should not have reduced, but will reduce after transition.
|
||||
*/
|
||||
public function test_status_transition_stock_restore_to_stock_reduce() {
|
||||
foreach ( $this->order_stock_restore_statuses as $order_status_from ) {
|
||||
|
@ -130,6 +134,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which restores stock to another status which also restores stock.
|
||||
* Stock should not have reduced, and will remain the same even after transition (i.e. should not be restocked again).
|
||||
*/
|
||||
public function test_status_transition_stock_restore_to_stock_restore() {
|
||||
foreach ( $this->order_stock_restore_statuses as $order_status_from ) {
|
||||
|
@ -141,6 +146,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which restores stock to another status which don't affect inventory.
|
||||
* Stock should not have reduced, and will remain the same even after transition.
|
||||
*/
|
||||
public function test_status_transition_stock_restore_to_stock_no_effect() {
|
||||
foreach ( $this->order_stock_restore_statuses as $order_status_from ) {
|
||||
|
@ -152,6 +158,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which don't affect inventory stock to another status which reduces stock.
|
||||
* Stock would not have been affected, but will reduce after transition.
|
||||
*/
|
||||
public function test_status_transition_stock_no_effect_to_stock_reduce() {
|
||||
foreach ( $this->order_stock_no_effect_statuses as $order_status_from ) {
|
||||
|
@ -163,6 +170,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which don't affect inventory stock to another status which restores stock.
|
||||
* Stock would not have been affected, and will not be restored after transition (since it was not reduced to begin with).
|
||||
*/
|
||||
public function test_status_transition_stock_no_effect_to_stock_restore() {
|
||||
foreach ( $this->order_stock_no_effect_statuses as $order_status_from ) {
|
||||
|
@ -174,6 +182,7 @@ class WC_Stock_Functions_Tests extends \WC_Unit_Test_Case {
|
|||
|
||||
/**
|
||||
* Test inventory count after order status transtions which don't affect inventory stock to another status which also don't affect inventory.
|
||||
* Stock levels will not change before or after the transition.
|
||||
*/
|
||||
public function test_status_transition_stock_no_effect_to_stock_no_effect() {
|
||||
foreach ( $this->order_stock_no_effect_statuses as $order_status_from ) {
|
||||
|
|
Loading…
Reference in New Issue