SwiftMailerUserMailerSpec::it_is_initializable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the BenGorUser package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace spec\BenGorUser\SwiftMailerBridge\Infrastructure\Mailing;
14
15
use BenGorUser\SwiftMailerBridge\Infrastructure\Mailing\SwiftMailerUserMailer;
16
use BenGorUser\User\Domain\Model\UserEmail;
17
use BenGorUser\User\Domain\Model\UserMailable;
18
use BenGorUser\User\Domain\Model\UserMailer;
19
use PhpSpec\ObjectBehavior;
20
21
/**
22
 * Spec file of SwiftMailerUserMailer class.
23
 *
24
 * @author Beñat Espiña <[email protected]>
25
 */
26
class SwiftMailerUserMailerSpec extends ObjectBehavior
27
{
28
    function let(\Swift_Mailer $mailer)
29
    {
30
        $this->beConstructedWith($mailer);
31
    }
32
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType(SwiftMailerUserMailer::class);
36
    }
37
38
    function it_implements_user_mailer()
39
    {
40
        $this->shouldImplement(UserMailer::class);
41
    }
42
43
    function it_mails(UserMailable $mail)
44
    {
45
        $to = new UserEmail('[email protected]');
46
47
        $mail->to()->shouldBeCalled()->willReturn($to);
48
        $mail->subject()->shouldBeCalled()->willReturn('Dummy subject');
49
        $mail->from()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
50
        $mail->bodyText()->shouldBeCalled()->willReturn('The email body');
51
        $mail->bodyHtml()->shouldBeCalled()->willReturn('<html>The email body</html>');
52
53
        $this->mail($mail);
54
    }
55
56
    function it_mails_with_multiples_receivers(UserMailable $mail)
57
    {
58
        $to = [
59
            new UserEmail('[email protected]'),
60
            new UserEmail('[email protected]'),
61
            new UserEmail('[email protected]'),
62
        ];
63
64
        $mail->to()->shouldBeCalled()->willReturn($to);
65
        $mail->subject()->shouldBeCalled()->willReturn('Dummy subject');
66
        $mail->from()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
67
        $mail->bodyText()->shouldBeCalled()->willReturn('The email body');
68
        $mail->bodyHtml()->shouldBeCalled()->willReturn('<html>The email body</html>');
69
70
        $this->mail($mail);
71
    }
72
}
73