SwiftMailerUserMailerSpec   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_user_mailer() 0 4 1
A it_mails() 0 12 1
A it_mails_with_multiples_receivers() 0 16 1
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