Completed
Push — master ( a818cb...b1c6ca )
by Kamil
07:13 queued 10s
created

OrderEmailManagerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_implements_an_order_email_manager_interface() 0 4 1
A it_sends_an_order_confirmation_email() 0 22 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\EmailManager;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\AdminBundle\EmailManager\OrderEmailManagerInterface;
18
use Sylius\Component\Core\Model\ChannelInterface;
19
use Sylius\Component\Core\Model\CustomerInterface;
20
use Sylius\Component\Core\Model\OrderInterface;
21
use Sylius\Component\Mailer\Sender\SenderInterface;
22
23
final class OrderEmailManagerSpec extends ObjectBehavior
24
{
25
    function let(SenderInterface $sender): void
26
    {
27
        $this->beConstructedWith($sender);
28
    }
29
30
    function it_implements_an_order_email_manager_interface(): void
31
    {
32
        $this->shouldImplement(OrderEmailManagerInterface::class);
33
    }
34
35
    function it_sends_an_order_confirmation_email(
36
        SenderInterface $sender,
37
        OrderInterface $order,
38
        ChannelInterface $channel,
39
        CustomerInterface $customer
40
    ): void {
41
        $order->getChannel()->willReturn($channel);
42
        $order->getLocaleCode()->willReturn('en_US');
43
        $order->getCustomer()->willReturn($customer);
44
        $customer->getEmail()->willReturn('[email protected]');
45
46
        $sender
47
            ->send('order_confirmation_resent', ['[email protected]'], [
48
                'order' => $order,
49
                'channel' => $channel,
50
                'localeCode' => 'en_US',
51
            ])
52
            ->shouldBeCalled()
53
        ;
54
55
        $this->sendConfirmationEmail($order);
56
    }
57
}
58