Completed
Push — npm-shrinkwrap ( 52ca24 )
by Kamil
23:13
created

ShipmentShipListenerSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 33
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_sends_a_confirmation_email() 0 11 1
A it_throws_an_invalid_argument_exception_if_an_event_subject_is_not_a_shipment_instance() 0 8 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
namespace spec\Sylius\Bundle\AdminBundle\EventListener;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Bundle\AdminBundle\EventListener\ShipmentShipListener;
16
use Sylius\Bundle\CoreBundle\EmailManager\ShipmentEmailManagerInterface;
17
use Sylius\Component\Core\Model\ShipmentInterface;
18
use Symfony\Component\EventDispatcher\GenericEvent;
19
20
/**
21
 * @author Grzegorz Sadowski <[email protected]>
22
 */
23
final class ShipmentShipListenerSpec extends ObjectBehavior
24
{
25
    function let(ShipmentEmailManagerInterface $shipmentEmailManager)
26
    {
27
        $this->beConstructedWith($shipmentEmailManager);
28
    }
29
30
    function it_is_initializable()
31
    {
32
        $this->shouldHaveType(ShipmentShipListener::class);
33
    }
34
35
    function it_sends_a_confirmation_email(
36
        ShipmentEmailManagerInterface $shipmentEmailManager,
37
        GenericEvent $event,
38
        ShipmentInterface $shipment
39
    ) {
40
        $event->getSubject()->willReturn($shipment);
41
42
        $shipmentEmailManager->sendConfirmationEmail($shipment)->shouldBeCalled();
43
44
        $this->sendConfirmationEmail($event);
45
    }
46
47
    function it_throws_an_invalid_argument_exception_if_an_event_subject_is_not_a_shipment_instance(
48
        GenericEvent $event,
49
        \stdClass $shipment
50
    ) {
51
        $event->getSubject()->willReturn($shipment);
52
53
        $this->shouldThrow(\InvalidArgumentException::class)->during('sendConfirmationEmail', [$event]);
54
    }
55
}
56