Skip to content

Commit

Permalink
test: increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianSDV authored and EdieLemoine committed Sep 20, 2024
1 parent 71fa340 commit 2ed71db
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/Unit/Pdk/Context/Service/WcContextServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MyParcelNL\Pdk\App\Cart\Contract\PdkCartRepositoryInterface;
use MyParcelNL\Pdk\App\ShippingMethod\Model\PdkShippingMethod;
use MyParcelNL\Pdk\Facade\Pdk;
use MyParcelNL\Pdk\Settings\Model\CheckoutSettings;
use MyParcelNL\WooCommerce\Tests\Uses\UsesMockWcPdkInstance;
use WC_Product;
use WC_Shipping_Flat_Rate;
Expand Down Expand Up @@ -50,7 +51,11 @@ function add_product_to_cart(?int $shippingClassId = null)
$contextService = Pdk::get(WcContextService::class);
$cartRepository = Pdk::get(PdkCartRepositoryInterface::class);

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

$shippingMethodClassName = $input['shippingMethod'];
$shippingClassId = $input['shippingClassId'] ?? null;
$shippingPrice = $input['shippingPrice'] ?? 0;
$termAsArray = $input['termAsArray'] ?? false;
Expand All @@ -75,10 +80,10 @@ function add_product_to_cart(?int $shippingClassId = null)
->make();
$pdkCart->shippingMethod = $pdkShippingMethod;

$shippingMethod = wpFactory($shippingClass)
$shippingMethod = wpFactory($shippingMethodClassName)
->withId(456);
if ($shippingPrice) {
$shippingMethod->instance_settings["class_cost_$wpTerm->term_id"] = $shippingPrice;
$shippingMethod->withInstanceSettings(['class_cost_12' => $shippingPrice]);
}
$shippingMethod->store();

Expand Down Expand Up @@ -107,7 +112,7 @@ function add_product_to_cart(?int $shippingClassId = null)
],
'expected' => [
'basePrice' => 0.0,
'highestShippingClass' => '',
'highestShippingClass' => 'shipping_class:12',
],
],
'product without shipping class' => [
Expand Down

0 comments on commit 2ed71db

Please sign in to comment.