Completed
Push — 1.0-travis-boom ( e4dcf7 )
by Kamil
268:40 queued 234:34
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
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
final class EmailProviderSpec extends ObjectBehavior
22
{
23
    function let(EmailFactoryInterface $emailFactory): void
24
    {
25
        $emails = [
26
            'user_confirmation' => [
27
                'enabled' => false,
28
                'subject' => 'Hello test!',
29
                'template' => 'SyliusMailerBundle::default.html.twig',
30
                'sender' => [
31
                    'name' => 'John Doe',
32
                    'address' => '[email protected]',
33
                ],
34
            ],
35
            'order_cancelled' => [
36
                'enabled' => false,
37
                'subject' => 'Hi test!',
38
                'template' => 'SyliusMailerBundle::default.html.twig',
39
                'sender' => [
40
                    'name' => 'Rick Doe',
41
                    'address' => '[email protected]',
42
                ],
43
            ],
44
        ];
45
46
        $this->beConstructedWith($emailFactory, $emails);
47
    }
48
49
    function it_implements_email_provider_interface(): void
50
    {
51
        $this->shouldImplement(EmailProviderInterface::class);
52
    }
53
54
    function it_looks_for_an_email_in_configuration_when_it_cannot_be_found_via_repository(
55
        EmailInterface $email,
56
        EmailFactoryInterface $emailFactory
57
    ): void {
58
        $emailFactory->createNew()->willReturn($email);
59
60
        $email->setCode('user_confirmation')->shouldBeCalled();
61
        $email->setSubject('Hello test!')->shouldBeCalled();
62
        $email->setTemplate('SyliusMailerBundle::default.html.twig')->shouldBeCalled();
63
        $email->setSenderName('John Doe')->shouldBeCalled();
64
        $email->setSenderAddress('[email protected]')->shouldBeCalled();
65
        $email->setEnabled(false)->shouldBeCalled();
66
67
        $this->getEmail('user_confirmation')->shouldReturn($email);
68
    }
69
}
70