Completed
Push — 1.1 ( 7e9455...13f0aa )
by Kamil
19:34
created

CartChangeListenerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

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);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Sylius\Component\...r\Model\OrderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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
42
    {
43
        $event->getSubject()->willReturn($orderItem);
44
        $orderItem->getOrder()->willReturn($order);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Sylius\Component\...r\Model\OrderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
46
        $order->removeItem($orderItem)->shouldBeCalled();
47
        $orderProcessor->process($order)->shouldBeCalled();
48
49
        $this->recalculateOrderOnDelete($event);
50
    }
51
}
52