blob: 038c7ef4cf86b2ae6fee58110cce86dc9742f3af (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
/*
* Tests for the Zotlabs\LibM̀ailer class.
*
* SPDX-FileCopyrightText: 2024 Hubzilla Community
* SPDX-FileContributor: Harald Eilertsen
*
* SPDX-License-Identifier: MIT
*/
namespace Zotlabs\Tests\Unit\Lib;
use App;
use phpmock\phpunit\PHPMock;
use Zotlabs\Lib\Mailer;
use Zotlabs\Tests\Unit\UnitTestCase;
class MailerTest extends UnitTestCase {
use PHPMock;
public function test_optional_params_replaced_by_defaults(): void {
$hostname = App::get_hostname();
$recipient = 'recipient@somesite.test';
$subject = 'A test email';
$body = <<<EOF
Dear recipient,
This is an test email message for you.
Sincerely,
Hubzilla
EOF;
//
// Catch calls to the php mail function, and verify
// that it is called with the args we're expecting
//
$this->getFunctionMock('Zotlabs\Lib', 'mail')
->expects($this->once())
->with(
$this->identicalTo($recipient),
$this->identicalTo($subject),
$this->identicalTo($body),
$this->identicalTo(<<<EOF
From: <Administrator@{$hostname}>
Reply-To: <noreply@{$hostname}>
Content-Type: text/plain; charset=UTF-8
EOF
)
)
->willReturn(true);
$mailer = new Mailer([
'toEmail' => $recipient,
'messageSubject' => $subject,
'textVersion' => $body,
]);
$mailer->deliver();
}
}
|