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; |
|
|
|
|
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; |
|
|
|
|
73
|
|
|
|
74
|
|
|
$this->mail($mail); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
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.