Completed
Push — reproduce-taxon-autocompletion ( 8c649e )
by Kamil
22:05
created

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