|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Nip\Mail\Tests\Models\Mailable; |
|
6
|
|
|
|
|
7
|
|
|
use Mockery\Mock; |
|
8
|
|
|
use Nip\Mail\Tests\AbstractTest; |
|
9
|
|
|
use Nip\Mail\Tests\Fixtures\Models\Emails\Email; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class RecordTraitTest. |
|
13
|
|
|
*/ |
|
14
|
|
|
class RecordTraitTest extends AbstractTest |
|
15
|
|
|
{ |
|
16
|
|
|
public function testBuildMailMessageMergeTagsStripNotPresent() |
|
17
|
|
|
{ |
|
18
|
|
|
$email = new Email(); |
|
19
|
|
|
$email->setBody('{{var1}}{{var3}}'); |
|
20
|
|
|
$email->setMergeTags(['var1' => 1, 'var2' => 2, 'var3' => 3]); |
|
21
|
|
|
|
|
22
|
|
|
$message = $email->newMailMessage(); |
|
23
|
|
|
$email->buildMailMessageMergeTags($message); |
|
24
|
|
|
|
|
25
|
|
|
$tags = $message->getMergeTags(); |
|
26
|
|
|
self::assertCount(2, $tags); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function test_body_get_setters() |
|
30
|
|
|
{ |
|
31
|
|
|
$email = new Email(); |
|
32
|
|
|
$email->writeData([ |
|
33
|
|
|
'body' => '{{var1}}{{var2}}', |
|
34
|
|
|
'merge_tags' => [ |
|
35
|
|
|
'var1' => 1, |
|
36
|
|
|
'var2' => 2, |
|
37
|
|
|
], |
|
38
|
|
|
]); |
|
39
|
|
|
|
|
40
|
|
|
self::assertSame('{{var1}}{{var2}}', $email->getBody()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function test_buildMailMessageRecipients() |
|
44
|
|
|
{ |
|
45
|
|
|
/** @var Mock|Email $email */ |
|
46
|
|
|
$email = \Mockery::mock(Email::class)->shouldAllowMockingProtectedMethods()->makePartial(); |
|
47
|
|
|
$email->writeData([ |
|
|
|
|
|
|
48
|
|
|
'to' => '[email protected], [email protected]', |
|
49
|
|
|
]); |
|
50
|
|
|
$email->bcc = [ |
|
|
|
|
|
|
51
|
|
|
'[email protected]' => 'Test 1', |
|
52
|
|
|
'[email protected]' => 'Test 2', |
|
53
|
|
|
]; |
|
54
|
|
|
|
|
55
|
|
|
$message = $email->newMailMessage(); |
|
|
|
|
|
|
56
|
|
|
$email->buildMailMessageRecipients($message); |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
$tos = $message->getTo(); |
|
59
|
|
|
self::assertCount(2, $tos); |
|
60
|
|
|
self::assertSame('[email protected]', $tos[1]->getAddress()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function test_buildMailMessageBody() |
|
64
|
|
|
{ |
|
65
|
|
|
$email = new Email(); |
|
66
|
|
|
$email->setBody('{{var1}}{{var2}}'); |
|
67
|
|
|
|
|
68
|
|
|
$message = $email->newMailMessage(); |
|
69
|
|
|
$message->addFrom('[email protected]'); |
|
70
|
|
|
$message->addTo('[email protected]'); |
|
71
|
|
|
|
|
72
|
|
|
$email->buildMailMessageBody($message); |
|
73
|
|
|
|
|
74
|
|
|
self::assertStringContainsString('{{var1}}{{var2}}', (string) $message->getBody()->toString()); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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.