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

ShipmentShipListenerSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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