Completed
Push — pull-request/8715 ( 14a000 )
by Kamil
29:06
created

EmailProviderSpec::let()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 17
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\Component\Mailer\Provider;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Mailer\Factory\EmailFactoryInterface;
18
use Sylius\Component\Mailer\Model\EmailInterface;
19
use Sylius\Component\Mailer\Provider\EmailProviderInterface;
20
21
/**
22
 * @author Paweł Jędrzejewski <[email protected]>
23
 */
24
final class EmailProviderSpec extends ObjectBehavior
25
{
26
    function let(EmailFactoryInterface $emailFactory): void
27
    {
28
        $emails = [
29
            'user_confirmation' => [
30
                'enabled' => false,
31
                'subject' => 'Hello test!',
32
                'template' => 'SyliusMailerBundle::default.html.twig',
33
                'sender' => [
34
                    'name' => 'John Doe',
35
                    'address' => '[email protected]',
36
                ],
37
            ],
38
            'order_cancelled' => [
39
                'enabled' => false,
40
                'subject' => 'Hi test!',
41
                'template' => 'SyliusMailerBundle::default.html.twig',
42
                'sender' => [
43
                    'name' => 'Rick Doe',
44
                    'address' => '[email protected]',
45
                ],
46
            ],
47
        ];
48
49
        $this->beConstructedWith($emailFactory, $emails);
50
    }
51
52
    function it_implements_email_provider_interface(): void
53
    {
54
        $this->shouldImplement(EmailProviderInterface::class);
55
    }
56
57
    function it_looks_for_an_email_in_configuration_when_it_cannot_be_found_via_repository(
58
        EmailInterface $email,
59
        EmailFactoryInterface $emailFactory
60
    ): void {
61
        $emailFactory->createNew()->willReturn($email);
62
63
        $email->setCode('user_confirmation')->shouldBeCalled();
64
        $email->setSubject('Hello test!')->shouldBeCalled();
65
        $email->setTemplate('SyliusMailerBundle::default.html.twig')->shouldBeCalled();
66
        $email->setSenderName('John Doe')->shouldBeCalled();
67
        $email->setSenderAddress('[email protected]')->shouldBeCalled();
68
        $email->setEnabled(false)->shouldBeCalled();
69
70
        $this->getEmail('user_confirmation')->shouldReturn($email);
71
    }
72
}
73