-
Notifications
You must be signed in to change notification settings - Fork 474
Expand file tree
/
Copy pathCollectionTest.php
More file actions
57 lines (43 loc) · 1.52 KB
/
CollectionTest.php
File metadata and controls
57 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
use Illuminate\Foundation\Testing\RefreshDatabase;
use Lunar\DataTypes\ShippingOption;
use Lunar\Models\Currency;
use Lunar\Models\TaxClass;
use Lunar\Shipping\DataTransferObjects\ShippingOptionRequest;
use Lunar\Shipping\Drivers\ShippingMethods\Collection;
use Lunar\Shipping\Models\ShippingMethod;
use Lunar\Shipping\Models\ShippingRate;
use Lunar\Shipping\Models\ShippingZone;
use Lunar\Tests\Shipping\TestCase;
use Lunar\Tests\Shipping\TestUtils;
uses(TestCase::class)->group('shipping', 'shipping-driver', 'shipping-driver-collection');
uses(RefreshDatabase::class);
uses(TestUtils::class);
test('can get free shipping', function () {
$currency = Currency::factory()->create([
'default' => true,
]);
TaxClass::factory()->create([
'default' => true,
]);
$shippingZone = ShippingZone::factory()->create([
'type' => 'countries',
]);
$shippingMethod = ShippingMethod::factory()->create([
'driver' => 'free-shipping',
'data' => [],
]);
$shippingRate = ShippingRate::factory()->create([
'shipping_method_id' => $shippingMethod->id,
'shipping_zone_id' => $shippingZone->id,
]);
$cart = $this->createCart($currency, 500);
$driver = new Collection;
$request = new ShippingOptionRequest(
cart: $cart,
shippingRate: $shippingRate
);
$shippingOption = $driver->resolve($request);
expect($shippingOption)->toBeInstanceOf(ShippingOption::class);
expect($shippingOption->price->value)->toEqual(0);
});