feat(Mailer): implement caching

Currently $this->instance is never set, so the code is no-op. This
brings back caching of the instance.

Caching broke with

   be7db1573d

   Swift to \Swift_Mailer as abstraction

Signed-off-by: Thomas Lehmann <t.lehmann@strato.de>
This commit is contained in:
Thomas Lehmann 2024-11-07 11:02:17 +01:00 committed by Thomas Lehmann
parent 6559c2075e
commit 46d8a7333b
2 changed files with 9 additions and 1 deletions

View file

@ -267,7 +267,9 @@ class Mailer implements IMailer {
break;
}
return new SymfonyMailer($transport);
$this->instance = new SymfonyMailer($transport);
return $this->instance;
}
/**

View file

@ -337,4 +337,10 @@ class MailerTest extends TestCase {
self::assertInstanceOf(EsmtpTransport::class, $transport);
self::assertEquals('[127.0.0.1]', $transport->getLocalDomain());
}
public function testCaching(): void {
$symfonyMailer1 = self::invokePrivate($this->mailer, 'getInstance');
$symfonyMailer2 = self::invokePrivate($this->mailer, 'getInstance');
self::assertSame($symfonyMailer1, $symfonyMailer2);
}
}