MandrillUserMailerSpec::it_mails()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 3
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\MandrillBridge\Infrastructure\Mailing;
14
15
use BenGorUser\MandrillBridge\Infrastructure\Mailing\MandrillUserMailer;
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 MandrillUserMailer class.
23
 *
24
 * @author Beñat Espiña <[email protected]>
25
 */
26
class MandrillUserMailerSpec extends ObjectBehavior
27
{
28
    function let(\Mandrill $mailer)
29
    {
30
        $this->beConstructedWith($mailer);
31
    }
32
33
    function it_is_initializable()
34
    {
35
        $this->shouldHaveType(MandrillUserMailer::class);
36
    }
37
38
    function it_implements_user_mailer()
39
    {
40
        $this->shouldImplement(UserMailer::class);
41
    }
42
43
    function it_mails(\Mandrill $mailer, \Mandrill_Messages $messages, 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
        $mailer->messages = $messages;
0 ignored issues
show
Bug introduced by
The property messages does not seem to exist in Mandrill.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
54
55
        $this->mail($mail);
56
    }
57
58
    function it_mails_with_multiples_receivers(\Mandrill $mailer, \Mandrill_Messages $messages, UserMailable $mail)
59
    {
60
        $to = [
61
            new UserEmail('[email protected]'),
62
            new UserEmail('[email protected]'),
63
            new UserEmail('[email protected]'),
64
        ];
65
66
        $mail->to()->shouldBeCalled()->willReturn($to);
67
        $mail->subject()->shouldBeCalled()->willReturn('Dummy subject');
68
        $mail->from()->shouldBeCalled()->willReturn(new UserEmail('[email protected]'));
69
        $mail->bodyText()->shouldBeCalled()->willReturn('The email body');
70
        $mail->bodyHtml()->shouldBeCalled()->willReturn('<html>The email body</html>');
71
72
        $mailer->messages = $messages;
0 ignored issues
show
Bug introduced by
The property messages does not seem to exist in Mandrill.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
73
74
        $this->mail($mail);
75
    }
76
}
77