Completed
Push — 1.0-make-tests-green-again ( 58c4e3 )
by Kamil
37:31
created

CartChangeListenerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_recalculates_cart_on_add() 0 10 1
A it_recalculates_cart_and_remove_item_on_delete() 0 10 1
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\Bundle\AdminApiBundle\EventListener;
15
16
use Doctrine\Common\Persistence\ObjectManager;
17
use PhpSpec\ObjectBehavior;
18
use Sylius\Component\Core\Model\OrderInterface;
19
use Sylius\Component\Core\Model\OrderItemInterface;
20
use Sylius\Component\Order\Processor\OrderProcessorInterface;
21
use Symfony\Component\EventDispatcher\GenericEvent;
22
23
final class CartChangeListenerSpec extends ObjectBehavior
24
{
25
    function let(OrderProcessorInterface $orderProcessor, ObjectManager $manager): void
26
    {
27
        $this->beConstructedWith($orderProcessor, $manager);
28
    }
29
30
    function it_recalculates_cart_on_add(OrderProcessorInterface $orderProcessor, ObjectManager $manager, GenericEvent $event, OrderItemInterface $orderItem, OrderInterface $order): void
31
    {
32
        $event->getSubject()->willReturn($orderItem);
33
        $orderItem->getOrder()->willReturn($order);
34
35
        $orderProcessor->process($order)->shouldBeCalled();
36
        $manager->persist($order)->shouldBeCalled();
37
38
        $this->recalculateOrderOnAdd($event);
39
    }
40
41
    function it_recalculates_cart_and_remove_item_on_delete(OrderProcessorInterface $orderProcessor, ObjectManager $manager, GenericEvent $event, OrderItemInterface $orderItem, OrderInterface $order): void
0 ignored issues
show
Unused Code introduced by
The parameter $manager is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        $event->getSubject()->willReturn($orderItem);
44
        $orderItem->getOrder()->willReturn($order);
45
46
        $order->removeItem($orderItem)->shouldBeCalled();
47
        $orderProcessor->process($order)->shouldBeCalled();
48
49
        $this->recalculateOrderOnDelete($event);
50
    }
51
}
52