Completed
Push — 1.0-symfony2-rename ( d9b26c )
by Kamil
83:12 queued 62:42
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
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);
0 ignored issues
show
Bug introduced by
The method willReturn() does not seem to exist on object<Sylius\Component\...r\Model\EmailInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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