aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Lehmann <t.lehmann@strato.de>2024-10-29 11:53:18 +0100
committerThomas Lehmann <147605810+thlehmann-ionos@users.noreply.github.com>2024-11-19 11:32:39 +0100
commite4c013d86d0802865aa2bac8fdda354cd2642788 (patch)
tree0495717c88f55f1cc7f00789ef3ca91b001ce813 /tests/lib
parent40211f3d0748983c294dcfffa56f4022bd69d28e (diff)
downloadnextcloud-server-e4c013d86d0802865aa2bac8fdda354cd2642788.tar.gz
nextcloud-server-e4c013d86d0802865aa2bac8fdda354cd2642788.zip
feat(Mailer): add "null" SMTP transport mode
== Goal Allow disabling mail delivery altogether. == Usecase If mails ought to be send by other means than rendering messages from templates and sending them via SMTP-like protocols. Example: listening to specific Nextcloud events and pass parameters to a centralized (i.e. REST-based) API that sends e-mails. Signed-off-by: Thomas Lehmann <t.lehmann@strato.de>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Mail/MailerTest.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index 84015f38d24..02a2605fc77 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -114,6 +114,26 @@ class MailerTest extends TestCase {
$this->assertEquals($sendmail, self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
+ public function testEventForNullTransport(): void {
+ $this->config
+ ->expects($this->exactly(1))
+ ->method('getSystemValueString')
+ ->with('mail_smtpmode', 'smtp')
+ ->willReturn('null');
+
+ $message = $this->createMock(Message::class);
+ $message->expects($this->once())
+ ->method('getSymfonyEmail')
+ ->willReturn((new Email())->to('foo@bar.com')->from('bar@foo.com')->text(''));
+
+ $event = new BeforeMessageSent($message);
+ $this->dispatcher->expects($this->once())
+ ->method('dispatchTyped')
+ ->with($this->equalTo($event));
+
+ $this->mailer->send($message);
+ }
+
public function testGetInstanceDefault(): void {
$this->config
->method('getSystemValue')