Completed
Push — 1.1 ( 9d9074...b5b13c )
by Kamil
23:25
created

OrderSpec::it_has_customer_ip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Core\Model;
15
16
use Doctrine\Common\Collections\Collection;
17
use PhpSpec\ObjectBehavior;
18
use Sylius\Component\Channel\Model\ChannelInterface;
19
use Sylius\Component\Core\Model\AddressInterface;
20
use Sylius\Component\Core\Model\AdjustmentInterface;
21
use Sylius\Component\Core\Model\CustomerInterface;
22
use Sylius\Component\Core\Model\OrderItemInterface;
23
use Sylius\Component\Core\Model\PaymentInterface;
24
use Sylius\Component\Core\Model\PromotionInterface;
25
use Sylius\Component\Core\Model\ShipmentInterface;
26
use Sylius\Component\Core\OrderCheckoutStates;
27
use Sylius\Component\Core\OrderShippingStates;
28
use Sylius\Component\Order\Model\Order as BaseOrder;
29
use Sylius\Component\Order\Model\OrderInterface;
30
use Sylius\Component\Promotion\Model\PromotionCouponInterface;
31
32
final class OrderSpec extends ObjectBehavior
33
{
34
    function it_implements_an_order_interface(): void
35
    {
36
        $this->shouldImplement(OrderInterface::class);
37
    }
38
39
    function it_extends_an_order(): void
40
    {
41
        $this->shouldHaveType(BaseOrder::class);
42
    }
43
44
    function it_does_not_have_a_customer_defined_by_default(): void
45
    {
46
        $this->getCustomer()->shouldReturn(null);
47
    }
48
49
    function its_allows_defining_customer(CustomerInterface $customer): void
50
    {
51
        $this->setCustomer($customer);
52
        $this->getCustomer()->shouldReturn($customer);
53
    }
54
55
    function its_customer_can_be_nullable(): void
56
    {
57
        $this->setCustomer(null);
58
        $this->getCustomer()->shouldReturn(null);
59
    }
60
61
    function its_channel_is_mutable(ChannelInterface $channel): void
62
    {
63
        $this->setChannel($channel);
64
        $this->getChannel()->shouldReturn($channel);
65
    }
66
67
    function it_does_not_have_shipping_address_by_default(): void
68
    {
69
        $this->getShippingAddress()->shouldReturn(null);
70
    }
71
72
    function it_allows_defining_shipping_address(AddressInterface $address): void
73
    {
74
        $this->setShippingAddress($address);
75
        $this->getShippingAddress()->shouldReturn($address);
76
    }
77
78
    function it_does_not_have_billing_address_by_default(): void
79
    {
80
        $this->getBillingAddress()->shouldReturn(null);
81
    }
82
83
    function it_allows_defining_billing_address(AddressInterface $address): void
84
    {
85
        $this->setBillingAddress($address);
86
        $this->getBillingAddress()->shouldReturn($address);
87
    }
88
89
    function its_checkout_state_is_mutable(): void
90
    {
91
        $this->setCheckoutState(OrderCheckoutStates::STATE_CART);
92
        $this->getCheckoutState()->shouldReturn(OrderCheckoutStates::STATE_CART);
93
    }
94
95
    function its_payment_state_is_mutable(): void
96
    {
97
        $this->setPaymentState(PaymentInterface::STATE_COMPLETED);
98
        $this->getPaymentState()->shouldReturn(PaymentInterface::STATE_COMPLETED);
99
    }
100
101
    function it_initializes_item_units_collection_by_default(): void
102
    {
103
        $this->getItemUnits()->shouldHaveType(Collection::class);
104
    }
105
106
    function it_initializes_shipments_collection_by_default(): void
107
    {
108
        $this->getShipments()->shouldHaveType(Collection::class);
109
    }
110
111
    function it_adds_shipment_properly(ShipmentInterface $shipment): void
112
    {
113
        $this->shouldNotHaveShipment($shipment);
114
115
        $shipment->setOrder($this)->shouldBeCalled();
116
        $this->addShipment($shipment);
117
118
        $this->shouldHaveShipment($shipment);
119
    }
120
121
    function it_removes_a_shipment_properly(ShipmentInterface $shipment): void
122
    {
123
        $shipment->setOrder($this)->shouldBeCalled();
124
        $this->addShipment($shipment);
125
126
        $this->shouldHaveShipment($shipment);
127
128
        $shipment->setOrder(null)->shouldBeCalled();
129
        $this->removeShipment($shipment);
130
131
        $this->shouldNotHaveShipment($shipment);
132
    }
133
134
    function it_removes_shipments(ShipmentInterface $shipment): void
135
    {
136
        $this->addShipment($shipment);
137
        $this->hasShipment($shipment)->shouldReturn(true);
138
139
        $this->removeShipments();
140
141
        $this->hasShipment($shipment)->shouldReturn(false);
142
    }
143
144
    function it_returns_shipping_adjustments(
145
        AdjustmentInterface $shippingAdjustment,
146
        AdjustmentInterface $taxAdjustment
147
    ): void {
148
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
149
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
150
        $shippingAdjustment->isNeutral()->willReturn(true);
151
152
        $taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
153
        $taxAdjustment->setAdjustable($this)->shouldBeCalled();
154
        $taxAdjustment->isNeutral()->willReturn(true);
155
156
        $this->addAdjustment($shippingAdjustment);
157
        $this->addAdjustment($taxAdjustment);
158
159
        $this->getAdjustments()->count()->shouldReturn(2);
160
161
        $shippingAdjustments = $this->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
162
        $shippingAdjustments->count()->shouldReturn(1);
163
        $shippingAdjustments->first()->shouldReturn($shippingAdjustment);
164
    }
165
166
    function it_removes_shipping_adjustments(
167
        AdjustmentInterface $shippingAdjustment,
168
        AdjustmentInterface $taxAdjustment
169
    ): void {
170
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
171
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
172
        $shippingAdjustment->isNeutral()->willReturn(true);
173
174
        $taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
175
        $taxAdjustment->setAdjustable($this)->shouldBeCalled();
176
        $taxAdjustment->isNeutral()->willReturn(true);
177
178
        $this->addAdjustment($shippingAdjustment);
179
        $this->addAdjustment($taxAdjustment);
180
181
        $this->getAdjustments()->count()->shouldReturn(2);
182
183
        $shippingAdjustment->isLocked()->willReturn(false);
184
        $shippingAdjustment->setAdjustable(null)->shouldBeCalled();
185
        $this->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT);
186
187
        $this->getAdjustments()->count()->shouldReturn(1);
188
        $this->getAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->count()->shouldReturn(0);
189
    }
190
191
    function it_returns_tax_adjustments(
192
        AdjustmentInterface $shippingAdjustment,
193
        AdjustmentInterface $taxAdjustment
194
    ): void {
195
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
196
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
197
        $shippingAdjustment->isNeutral()->willReturn(true);
198
199
        $taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
200
        $taxAdjustment->setAdjustable($this)->shouldBeCalled();
201
        $taxAdjustment->isNeutral()->willReturn(true);
202
203
        $this->addAdjustment($shippingAdjustment);
204
        $this->addAdjustment($taxAdjustment);
205
206
        $this->getAdjustments()->count()->shouldReturn(2);
207
208
        $taxAdjustments = $this->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT);
209
        $taxAdjustments->count()->shouldReturn(1);
210
        $taxAdjustments->first()->shouldReturn($taxAdjustment);
211
    }
212
213
    function it_removes_tax_adjustments(
214
        AdjustmentInterface $shippingAdjustment,
215
        AdjustmentInterface $taxAdjustment
216
    ): void {
217
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
218
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
219
        $shippingAdjustment->isNeutral()->willReturn(true);
220
221
        $taxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
222
        $taxAdjustment->setAdjustable($this)->shouldBeCalled();
223
        $taxAdjustment->isNeutral()->willReturn(true);
224
225
        $this->addAdjustment($shippingAdjustment);
226
        $this->addAdjustment($taxAdjustment);
227
228
        $this->getAdjustments()->count()->shouldReturn(2);
229
230
        $taxAdjustment->isLocked()->willReturn(false);
231
        $taxAdjustment->setAdjustable(null)->shouldBeCalled();
232
        $this->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT);
233
234
        $this->getAdjustments()->count()->shouldReturn(1);
235
        $this->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->count()->shouldReturn(0);
236
    }
237
238
    function it_does_not_have_a_currency_code_defined_by_default(): void
239
    {
240
        $this->getCurrencyCode()->shouldReturn(null);
241
    }
242
243
    function it_allows_defining_a_currency_code(): void
244
    {
245
        $this->setCurrencyCode('PLN');
246
        $this->getCurrencyCode()->shouldReturn('PLN');
247
    }
248
249
    function it_has_no_default_locale_code(): void
250
    {
251
        $this->getLocaleCode()->shouldReturn(null);
252
    }
253
254
    function its_locale_code_is_mutable(): void
255
    {
256
        $this->setLocaleCode('en');
257
        $this->getLocaleCode()->shouldReturn('en');
258
    }
259
260
    function it_has_a_cart_shipping_state_by_default(): void
261
    {
262
        $this->getShippingState()->shouldReturn(OrderShippingStates::STATE_CART);
263
    }
264
265
    function its_shipping_state_is_mutable(): void
266
    {
267
        $this->setShippingState(OrderShippingStates::STATE_SHIPPED);
268
        $this->getShippingState()->shouldReturn(OrderShippingStates::STATE_SHIPPED);
269
    }
270
271
    function it_adds_and_removes_payments(PaymentInterface $payment): void
272
    {
273
        $payment->getState()->willReturn(PaymentInterface::STATE_NEW);
274
        $payment->setOrder($this)->shouldBeCalled();
275
276
        $this->addPayment($payment);
277
        $this->shouldHavePayment($payment);
278
279
        $payment->setOrder(null)->shouldBeCalled();
280
281
        $this->removePayment($payment);
282
        $this->shouldNotHavePayment($payment);
283
    }
284
285
    function it_returns_last_payment_with_given_state(
286
        PaymentInterface $payment1,
287
        PaymentInterface $payment2,
288
        PaymentInterface $payment3,
289
        PaymentInterface $payment4
290
    ): void {
291
        $payment1->getState()->willReturn(PaymentInterface::STATE_CART);
292
        $payment1->setOrder($this)->shouldBeCalled();
293
294
        $payment2->getState()->willReturn(PaymentInterface::STATE_CANCELLED);
295
        $payment2->setOrder($this)->shouldBeCalled();
296
297
        $payment3->getState()->willReturn(PaymentInterface::STATE_PROCESSING);
298
        $payment3->setOrder($this)->shouldBeCalled();
299
300
        $payment4->getState()->willReturn(PaymentInterface::STATE_FAILED);
301
        $payment4->setOrder($this)->shouldBeCalled();
302
303
        $this->addPayment($payment1);
304
        $this->addPayment($payment2);
305
        $this->addPayment($payment3);
306
        $this->addPayment($payment4);
307
308
        $this->getLastPayment(OrderInterface::STATE_CART)->shouldReturn($payment1);
309
    }
310
311
    function it_returns_a_null_if_there_is_no_payments_after_trying_to_get_last_payment(): void
312
    {
313
        $this->getLastPayment(OrderInterface::STATE_CART)->shouldReturn(null);
314
    }
315
316
    function it_returns_last_payment_with_any_state_if_there_is_no_target_state_specified(
317
        PaymentInterface $payment1,
318
        PaymentInterface $payment2,
319
        PaymentInterface $payment3,
320
        PaymentInterface $payment4
321
    ): void {
322
        $payment1->getState()->willReturn(PaymentInterface::STATE_CART);
323
        $payment1->setOrder($this)->shouldBeCalled();
324
325
        $payment2->getState()->willReturn(PaymentInterface::STATE_CANCELLED);
326
        $payment2->setOrder($this)->shouldBeCalled();
327
328
        $payment3->getState()->willReturn(PaymentInterface::STATE_PROCESSING);
329
        $payment3->setOrder($this)->shouldBeCalled();
330
331
        $payment4->getState()->willReturn(PaymentInterface::STATE_FAILED);
332
        $payment4->setOrder($this)->shouldBeCalled();
333
334
        $this->addPayment($payment1);
335
        $this->addPayment($payment2);
336
        $this->addPayment($payment3);
337
        $this->addPayment($payment4);
338
339
        $this->getLastPayment()->shouldReturn($payment4);
340
    }
341
342
    function it_adds_and_removes_shipments(ShipmentInterface $shipment): void
343
    {
344
        $shipment->setOrder($this)->shouldBeCalled();
345
346
        $this->addShipment($shipment);
347
        $this->shouldHaveShipment($shipment);
348
349
        $shipment->setOrder(null)->shouldBeCalled();
350
351
        $this->removeShipment($shipment);
352
        $this->shouldNotHaveShipment($shipment);
353
    }
354
355
    function it_has_a_promotion_coupon(PromotionCouponInterface $coupon): void
356
    {
357
        $this->setPromotionCoupon($coupon);
358
        $this->getPromotionCoupon()->shouldReturn($coupon);
359
    }
360
361
    function it_counts_promotions_subjects(OrderItemInterface $item1, OrderItemInterface $item2): void
362
    {
363
        $item1->getQuantity()->willReturn(4);
364
        $item1->getTotal()->willReturn(420);
365
        $item1->setOrder($this)->will(function () {});
366
367
        $item2->getQuantity()->willReturn(3);
368
        $item2->getTotal()->willReturn(666);
369
        $item2->setOrder($this)->will(function () {});
370
371
        $this->addItem($item1);
372
        $this->addItem($item2);
373
374
        $this->getPromotionSubjectCount()->shouldReturn(7);
375
    }
376
377
    function it_adds_and_removes_promotions(PromotionInterface $promotion): void
378
    {
379
        $this->addPromotion($promotion);
380
        $this->shouldHavePromotion($promotion);
381
382
        $this->removePromotion($promotion);
383
        $this->shouldNotHavePromotion($promotion);
384
    }
385
386
    function it_returns_0_tax_total_when_there_are_no_items_and_adjustments(): void
387
    {
388
        $this->getTaxTotal()->shouldReturn(0);
389
    }
390
391
    function it_returns_a_tax_of_all_items_as_tax_total_when_there_are_no_tax_adjustments(
392
        OrderItemInterface $orderItem1,
393
        OrderItemInterface $orderItem2
394
    ): void {
395
        $orderItem1->getTotal()->willReturn(1100);
396
        $orderItem1->getTaxTotal()->willReturn(100);
397
        $orderItem2->getTotal()->willReturn(1050);
398
        $orderItem2->getTaxTotal()->willReturn(50);
399
400
        $orderItem1->setOrder($this)->shouldBeCalled();
401
        $orderItem2->setOrder($this)->shouldBeCalled();
402
        $this->addItem($orderItem1);
403
        $this->addItem($orderItem2);
404
405
        $this->getTaxTotal()->shouldReturn(150);
406
    }
407
408
    function it_returns_a_tax_of_all_items_and_non_neutral_shipping_tax_as_tax_total(
409
        OrderItemInterface $orderItem1,
410
        OrderItemInterface $orderItem2,
411
        AdjustmentInterface $shippingAdjustment,
412
        AdjustmentInterface $shippingTaxAdjustment
413
    ): void {
414
        $orderItem1->getTotal()->willReturn(1100);
415
        $orderItem1->getTaxTotal()->willReturn(100);
416
        $orderItem2->getTotal()->willReturn(1050);
417
        $orderItem2->getTaxTotal()->willReturn(50);
418
419
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
420
        $shippingAdjustment->isNeutral()->willReturn(false);
421
        $shippingAdjustment->getAmount()->willReturn(1000);
422
        $shippingTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
423
        $shippingTaxAdjustment->isNeutral()->willReturn(false);
424
        $shippingTaxAdjustment->getAmount()->willReturn(70);
425
426
        $orderItem1->setOrder($this)->shouldBeCalled();
427
        $orderItem2->setOrder($this)->shouldBeCalled();
428
        $this->addItem($orderItem1);
429
        $this->addItem($orderItem2);
430
431
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
432
        $this->addAdjustment($shippingAdjustment);
433
434
        $shippingTaxAdjustment->setAdjustable($this)->shouldBeCalled();
435
        $this->addAdjustment($shippingTaxAdjustment);
436
437
        $this->getTaxTotal()->shouldReturn(220);
438
    }
439
440
    function it_returns_a_tax_of_all_items_and_neutral_shipping_tax_as_tax_total(
441
        OrderItemInterface $orderItem1,
442
        OrderItemInterface $orderItem2,
443
        AdjustmentInterface $shippingAdjustment,
444
        AdjustmentInterface $shippingTaxAdjustment
445
    ): void {
446
        $orderItem1->getTotal()->willReturn(1100);
447
        $orderItem1->getTaxTotal()->willReturn(100);
448
        $orderItem2->getTotal()->willReturn(1050);
449
        $orderItem2->getTaxTotal()->willReturn(50);
450
451
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
452
        $shippingAdjustment->isNeutral()->willReturn(false);
453
        $shippingAdjustment->getAmount()->willReturn(1000);
454
455
        $shippingTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
456
        $shippingTaxAdjustment->isNeutral()->willReturn(true);
457
        $shippingTaxAdjustment->getAmount()->willReturn(70);
458
459
        $orderItem1->setOrder($this)->shouldBeCalled();
460
        $orderItem2->setOrder($this)->shouldBeCalled();
461
        $this->addItem($orderItem1);
462
        $this->addItem($orderItem2);
463
464
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
465
        $shippingTaxAdjustment->setAdjustable($this)->shouldBeCalled();
466
        $this->addAdjustment($shippingAdjustment);
467
        $this->addAdjustment($shippingTaxAdjustment);
468
469
        $this->getTaxTotal()->shouldReturn(220);
470
    }
471
472
    function it_includes_a_non_neutral_tax_adjustments_in_shipping_total(
473
        AdjustmentInterface $shippingAdjustment,
474
        AdjustmentInterface $shippingTaxAdjustment
475
    ): void {
476
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
477
        $shippingAdjustment->isNeutral()->willReturn(false);
478
        $shippingAdjustment->getAmount()->willReturn(1000);
479
480
        $shippingTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
481
        $shippingTaxAdjustment->isNeutral()->willReturn(false);
482
        $shippingTaxAdjustment->getAmount()->willReturn(70);
483
484
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
485
        $shippingTaxAdjustment->setAdjustable($this)->shouldBeCalled();
486
        $this->addAdjustment($shippingAdjustment);
487
        $this->addAdjustment($shippingTaxAdjustment);
488
489
        $this->getShippingTotal()->shouldReturn(1070);
490
    }
491
492
    function it_returns_a_shipping_total_decreased_by_shipping_promotion(
493
        AdjustmentInterface $shippingAdjustment,
494
        AdjustmentInterface $shippingTaxAdjustment,
495
        AdjustmentInterface $shippingPromotionAdjustment
496
    ): void {
497
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
498
        $shippingAdjustment->isNeutral()->willReturn(false);
499
        $shippingAdjustment->getAmount()->willReturn(1000);
500
501
        $shippingTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
502
        $shippingTaxAdjustment->isNeutral()->willReturn(false);
503
        $shippingTaxAdjustment->getAmount()->willReturn(70);
504
505
        $shippingPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT);
506
        $shippingPromotionAdjustment->isNeutral()->willReturn(false);
507
        $shippingPromotionAdjustment->getAmount()->willReturn(-100);
508
509
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
510
        $shippingTaxAdjustment->setAdjustable($this)->shouldBeCalled();
511
        $shippingPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
512
        $this->addAdjustment($shippingAdjustment);
513
        $this->addAdjustment($shippingTaxAdjustment);
514
        $this->addAdjustment($shippingPromotionAdjustment);
515
516
        $this->getShippingTotal()->shouldReturn(970);
517
    }
518
519
    function it_does_not_include_neutral_tax_adjustments_in_shipping_total(
520
        AdjustmentInterface $shippingAdjustment,
521
        AdjustmentInterface $neutralShippingTaxAdjustment
522
    ): void {
523
        $shippingAdjustment->getType()->willReturn(AdjustmentInterface::SHIPPING_ADJUSTMENT);
524
        $shippingAdjustment->isNeutral()->willReturn(false);
525
        $shippingAdjustment->getAmount()->willReturn(1000);
526
527
        $neutralShippingTaxAdjustment->getType()->willReturn(AdjustmentInterface::TAX_ADJUSTMENT);
528
        $neutralShippingTaxAdjustment->isNeutral()->willReturn(true);
529
        $neutralShippingTaxAdjustment->getAmount()->willReturn(70);
530
531
        $shippingAdjustment->setAdjustable($this)->shouldBeCalled();
532
        $neutralShippingTaxAdjustment->setAdjustable($this)->shouldBeCalled();
533
        $this->addAdjustment($shippingAdjustment);
534
        $this->addAdjustment($neutralShippingTaxAdjustment);
535
536
        $this->getShippingTotal()->shouldReturn(1000);
537
    }
538
539
    function it_returns_0_as_promotion_total_when_there_are_no_order_promotion_adjustments(): void
540
    {
541
        $this->getOrderPromotionTotal()->shouldReturn(0);
542
    }
543
544
    function it_returns_a_sum_of_all_order_promotion_adjustments_applied_to_items_as_order_promotion_total(
545
        OrderItemInterface $orderItem1,
546
        OrderItemInterface $orderItem2
547
    ): void {
548
        $orderItem1->getTotal()->willReturn(500);
549
        $orderItem2->getTotal()->willReturn(300);
550
551
        $orderItem1->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(-400);
552
        $orderItem2->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(-600);
553
554
        $orderItem1->setOrder($this)->shouldBeCalled();
555
        $orderItem2->setOrder($this)->shouldBeCalled();
556
        $this->addItem($orderItem1);
557
        $this->addItem($orderItem2);
558
559
        $this->getOrderPromotionTotal()->shouldReturn(-1000);
560
    }
561
562
    function it_does_not_include_a_shipping_promotion_adjustment_in_order_promotion_total(
563
        AdjustmentInterface $shippingPromotionAdjustment,
564
        OrderItemInterface $orderItem1
565
    ): void {
566
        $orderItem1->getTotal()->willReturn(500);
567
        $orderItem1->getAdjustmentsTotalRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(-400);
568
569
        $shippingPromotionAdjustment->getType()->willReturn(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT);
570
        $shippingPromotionAdjustment->isNeutral()->willReturn(false);
571
        $shippingPromotionAdjustment->getAmount()->willReturn(-100);
572
573
        $orderItem1->setOrder($this)->shouldBeCalled();
574
        $this->addItem($orderItem1);
575
576
        $shippingPromotionAdjustment->setAdjustable($this)->shouldBeCalled();
577
        $this->addAdjustment($shippingPromotionAdjustment);
578
579
        $this->getOrderPromotionTotal()->shouldReturn(-400);
580
    }
581
582
    function it_has_a_token_value(): void
583
    {
584
        $this->setTokenValue('xyzasdxqwe');
585
586
        $this->getTokenValue()->shouldReturn('xyzasdxqwe');
587
    }
588
589
    function it_has_customer_ip(): void
590
    {
591
        $this->setCustomerIp('172.16.254.1');
592
        $this->getCustomerIp()->shouldReturn('172.16.254.1');
593
    }
594
}
595