Skip to content

Commit

Permalink
test: add testcase for no allowed shipping methods
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianSDV committed Sep 27, 2024
1 parent ee702fd commit e5419cc
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/Unit/Pdk/Context/Service/WcContextServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function add_product_to_cart(?int $shippingClassId = null)
$cartRepository = Pdk::get(PdkCartRepositoryInterface::class);

factory(CheckoutSettings::class)
->withAllowedShippingMethods(['-1' => ['shipping_class:12']])
->withAllowedShippingMethods(['-1' => $input['allowShippingMethods']])
->store();

$shippingMethodClassName = $input['shippingMethod'];
Expand Down Expand Up @@ -96,6 +96,7 @@ function add_product_to_cart(?int $shippingClassId = null)
})->with([
'flexible shipping' => [
'input' => [
'allowShippingMethods' => ['shipping_class:12'],
'shippingMethod' => WC_Shipping_Method::class,
'shippingClassId' => 12,
],
Expand All @@ -106,6 +107,7 @@ function add_product_to_cart(?int $shippingClassId = null)
],
'flat rate with price' => [
'input' => [
'allowShippingMethods' => ['shipping_class:12'],
'shippingMethod' => WC_Shipping_Flat_Rate::class,
'shippingClassId' => 12,
'shippingPrice' => 5.12,
Expand All @@ -117,6 +119,7 @@ function add_product_to_cart(?int $shippingClassId = null)
],
'product without shipping class' => [
'input' => [
'allowShippingMethods' => ['shipping_class:12'],
'shippingMethod' => WC_Shipping_Flat_Rate::class,
],
'expected' => [
Expand All @@ -126,6 +129,7 @@ function add_product_to_cart(?int $shippingClassId = null)
],
'flat rate without price' => [
'input' => [
'allowShippingMethods' => ['shipping_class:12'],
'shippingMethod' => WC_Shipping_Flat_Rate::class,
'shippingClassId' => 12,
],
Expand All @@ -136,6 +140,7 @@ function add_product_to_cart(?int $shippingClassId = null)
],
'term as array' => [
'input' => [
'allowShippingMethods' => ['shipping_class:12'],
'shippingMethod' => WC_Shipping_Flat_Rate::class,
'shippingClassId' => 12,
'termAsArray' => true,
Expand All @@ -145,4 +150,15 @@ function add_product_to_cart(?int $shippingClassId = null)
'highestShippingClass' => '',
],
],
'no allowed shipping methods' => [
'input' => [
'allowShippingMethods' => [],
'shippingMethod' => WC_Shipping_Method::class,
'shippingClassId' => 12,
],
'expected' => [
'basePrice' => 0.0,
'highestShippingClass' => '',
],
],
]);

0 comments on commit e5419cc

Please sign in to comment.