Completed
Push — template-events ( d018fc...2e9f01 )
by Kamil
65:59 queued 42:59
created

CartChangeListenerSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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
namespace spec\Sylius\Bundle\ApiBundle\EventListener;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Bundle\ApiBundle\EventListener\CartChangeListener;
17
use Sylius\Component\Core\Model\OrderInterface;
18
use Sylius\Component\Core\Model\OrderItemInterface;
19
use Sylius\Component\Order\Processor\OrderProcessorInterface;
20
use Symfony\Component\EventDispatcher\GenericEvent;
21
22
final class CartChangeListenerSpec extends ObjectBehavior
23
{
24
    function let(OrderProcessorInterface $orderProcessor, ObjectManager $manager)
25
    {
26
        $this->beConstructedWith($orderProcessor, $manager);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType(CartChangeListener::class);
32
    }
33
34
    function it_recalculates_cart_on_add(OrderProcessorInterface $orderProcessor, ObjectManager $manager, GenericEvent $event, OrderItemInterface $orderItem, OrderInterface $order)
35
    {
36
        $event->getSubject()->willReturn($orderItem);
37
        $orderItem->getOrder()->willReturn($order);
38
39
        $orderProcessor->process($order)->shouldBeCalled();
40
        $manager->persist($order)->shouldBeCalled();
41
42
        $this->recalculateOrderOnAdd($event);
43
    }
44
45
    function it_recalculates_cart_and_remove_item_on_delete(OrderProcessorInterface $orderProcessor, ObjectManager $manager, GenericEvent $event, OrderItemInterface $orderItem, OrderInterface $order)
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...
46
    {
47
        $event->getSubject()->willReturn($orderItem);
48
        $orderItem->getOrder()->willReturn($order);
49
50
        $order->removeItem($orderItem)->shouldBeCalled();
51
        $orderProcessor->process($order)->shouldBeCalled();
52
53
        $this->recalculateOrderOnDelete($event);
54
    }
55
}
56