Completed
Push — 1.0-readme ( 535e7a )
by Kamil
28:54
created

ShipmentShipListenerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 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
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