Completed
Push — 1.0-readme ( 535e7a )
by Kamil
28:54
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Bundle\AdminBundle\EventListener;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\AdminBundle\EmailManager\ShipmentEmailManagerInterface;
18
use Sylius\Component\Core\Model\ShipmentInterface;
19
use Symfony\Component\EventDispatcher\GenericEvent;
20
21
final class ShipmentShipListenerSpec extends ObjectBehavior
22
{
23
    function let(ShipmentEmailManagerInterface $shipmentEmailManager): void
24
    {
25
        $this->beConstructedWith($shipmentEmailManager);
26
    }
27
28
    function it_sends_a_confirmation_email(
29
        ShipmentEmailManagerInterface $shipmentEmailManager,
30
        GenericEvent $event,
31
        ShipmentInterface $shipment
32
    ): void {
33
        $event->getSubject()->willReturn($shipment);
34
35
        $shipmentEmailManager->sendConfirmationEmail($shipment)->shouldBeCalled();
36
37
        $this->sendConfirmationEmail($event);
38
    }
39
40
    function it_throws_an_invalid_argument_exception_if_an_event_subject_is_not_a_shipment_instance(
41
        GenericEvent $event,
42
        \stdClass $shipment
43
    ): void {
44
        $event->getSubject()->willReturn($shipment);
45
46
        $this->shouldThrow(\InvalidArgumentException::class)->during('sendConfirmationEmail', [$event]);
47
    }
48
}
49