Code Duplication    Length = 15-19 lines in 6 locations

src/Sylius/Component/Order/spec/Model/OrderItemSpec.php 4 locations

@@ 263-277 (lines=15) @@
260
        $this->getTotal()->shouldReturn(1998);
261
    }
262
263
    function it_has_correct_total_after_adjustment_add_and_remove(AdjustmentInterface $adjustment)
264
    {
265
        $adjustment->isNeutral()->willReturn(false);
266
        $adjustment->getAmount()->willReturn(200);
267
        $adjustment->setAdjustable($this)->shouldBeCalled();
268
269
        $this->addAdjustment($adjustment);
270
        $this->getTotal()->shouldReturn(200);
271
272
        $adjustment->setAdjustable(null)->shouldBeCalled();
273
        $adjustment->isLocked()->willReturn(false);
274
275
        $this->removeAdjustment($adjustment);
276
        $this->getTotal()->shouldReturn(0);
277
    }
278
279
    function it_has_correct_total_after_neutral_adjustment_add_and_remove(AdjustmentInterface $adjustment)
280
    {
@@ 279-293 (lines=15) @@
276
        $this->getTotal()->shouldReturn(0);
277
    }
278
279
    function it_has_correct_total_after_neutral_adjustment_add_and_remove(AdjustmentInterface $adjustment)
280
    {
281
        $adjustment->isNeutral()->willReturn(true);
282
        $adjustment->getAmount()->willReturn(200);
283
        $adjustment->setAdjustable($this)->shouldBeCalled();
284
285
        $this->addAdjustment($adjustment);
286
        $this->getTotal()->shouldReturn(0);
287
288
        $adjustment->setAdjustable(null)->shouldBeCalled();
289
        $adjustment->isLocked()->willReturn(false);
290
291
        $this->removeAdjustment($adjustment);
292
        $this->getTotal()->shouldReturn(0);
293
    }
294
295
    function it_has_0_total_when_adjustment_decreases_total_under_0(
296
        AdjustmentInterface $adjustment,
@@ 295-309 (lines=15) @@
292
        $this->getTotal()->shouldReturn(0);
293
    }
294
295
    function it_has_0_total_when_adjustment_decreases_total_under_0(
296
        AdjustmentInterface $adjustment,
297
        OrderItemUnitInterface $orderItemUnit1
298
    ) {
299
        $orderItemUnit1->getOrderItem()->willReturn($this->getWrappedObject());
300
        $orderItemUnit1->getTotal()->willReturn(1499);
301
302
        $adjustment->isNeutral()->willReturn(false);
303
        $adjustment->getAmount()->willReturn(-2000);
304
        $adjustment->setAdjustable($this)->shouldBeCalled();
305
306
        $this->addUnit($orderItemUnit1);
307
        $this->addAdjustment($adjustment);
308
        $this->getTotal()->shouldReturn(0);
309
    }
310
311
    function it_has_correct_total_after_unit_price_change(
312
        OrderItemUnitInterface $orderItemUnit1,
@@ 363-378 (lines=16) @@
360
        $this->getTotal()->shouldReturn(400);
361
    }
362
363
    function it_returns_correct_adjustments_total(
364
        AdjustmentInterface $adjustment1,
365
        AdjustmentInterface $adjustment2
366
    ) {
367
        $adjustment1->getAmount()->willReturn(100);
368
        $adjustment1->isNeutral()->willReturn(false);
369
        $adjustment1->setAdjustable($this)->shouldBeCalled();
370
        $adjustment2->getAmount()->willReturn(500);
371
        $adjustment2->isNeutral()->willReturn(false);
372
        $adjustment2->setAdjustable($this)->shouldBeCalled();
373
374
        $this->addAdjustment($adjustment1);
375
        $this->addAdjustment($adjustment2);
376
377
        $this->getAdjustmentsTotal()->shouldReturn(600);
378
    }
379
380
    function it_returns_correct_adjustments_total_by_type(
381
        AdjustmentInterface $adjustment1,

src/Sylius/Component/Order/spec/Model/OrderItemUnitSpec.php 1 location

@@ 144-162 (lines=19) @@
141
        $this->getTotal()->shouldReturn(1300);
142
    }
143
144
    function it_has_correct_total_after_neutral_adjustment_add_and_remove(
145
        AdjustmentInterface $adjustment,
146
        OrderItemInterface $orderItem
147
    ) {
148
        $orderItem->recalculateUnitsTotal()->shouldBeCalled();
149
150
        $adjustment->isNeutral()->willReturn(true);
151
        $adjustment->getAmount()->willReturn(200);
152
        $adjustment->setAdjustable($this)->shouldBeCalled();
153
154
        $this->addAdjustment($adjustment);
155
        $this->getTotal()->shouldReturn(1000);
156
157
        $adjustment->setAdjustable(null)->shouldBeCalled();
158
        $adjustment->isLocked()->willReturn(false);
159
160
        $this->removeAdjustment($adjustment);
161
        $this->getTotal()->shouldReturn(1000);
162
    }
163
164
    function it_has_proper_total_after_order_item_unit_price_change(
165
        AdjustmentInterface $adjustment1,

src/Sylius/Component/Order/spec/Model/OrderSpec.php 1 location

@@ 446-463 (lines=18) @@
443
        $this->getTotal()->shouldReturn(70000);
444
    }
445
446
    function it_calculates_correct_total_when_adjustment_is_bigger_than_cost(OrderItemInterface $item, AdjustmentInterface $adjustment)
447
    {
448
        $item->getTotal()->willReturn(45000);
449
450
        $item->equals(Argument::any())->willReturn(false);
451
452
        $item->setOrder($this)->shouldBeCalled();
453
454
        $adjustment->isNeutral()->willReturn(false);
455
        $adjustment->getAmount()->willReturn(-100000);
456
457
        $adjustment->setAdjustable($this)->shouldBeCalled();
458
459
        $this->addItem($item);
460
        $this->addAdjustment($adjustment);
461
462
        $this->getTotal()->shouldReturn(0);
463
    }
464
465
    function it_initializes_creation_date_by_default()
466
    {