19 declare(strict_types=1);
31 protected function setUp(): void
44 $defaultTransport = $this->getMockBuilder(ilMailMimeTransport::class)->disableOriginalConstructor()->getMock();
45 $defaultTransport->expects($this->never())->method(
'send');
47 $transport = $this->getMockBuilder(ilMailMimeTransport::class)->getMock();
48 $transport->expects($this->once())->method(
'send');
50 $transportFactory = $this->getMockBuilder(ilMailMimeTransportFactory::class)->disableOriginalConstructor()->getMock();
51 $transportFactory->method(
'getTransport')->willReturn($defaultTransport);
54 $refineryMock = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock();
57 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
64 $mail->Send($transport);
72 $defaultTransport = $this->getMockBuilder(ilMailMimeTransport::class)->getMock();
73 $defaultTransport->expects($this->once())->method(
'send');
75 $transportFactory = $this->getMockBuilder(ilMailMimeTransportFactory::class)->disableOriginalConstructor()->getMock();
76 $transportFactory->method(
'getTransport')->willReturn($defaultTransport);
79 $refineryMock = $this->getMockBuilder(Factory::class)->disableOriginalConstructor()->getMock();
82 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
97 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
101 $settings->method(
'get')->willReturnCallback(
static function ($key): ?
string {
102 return (
string) (
'mail_allow_external' !== $key);
106 $eventHandler = $this->getMockBuilder(ilAppEventHandler::class)->disableOriginalConstructor()->onlyMethods([
111 $this->assertInstanceOf(ilMailMimeTransportNull::class, $factory->getTransport());
119 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
123 $settings->method(
'get')->willReturnCallback(
static function ($key): ?
string {
128 $eventHandler = $this->getMockBuilder(ilAppEventHandler::class)->disableOriginalConstructor()->onlyMethods([
133 $this->assertInstanceOf(ilMailMimeTransportSmtp::class, $factory->getTransport());
141 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
146 $settings->method(
'get')->willReturnCallback(
static function ($key): ?
string {
147 if (
'mail_allow_external' === $key) {
152 if (
'mail_smtp_status' === $key) {
160 $eventHandler = $this->getMockBuilder(ilAppEventHandler::class)->disableOriginalConstructor()->onlyMethods([
165 $this->assertInstanceOf(ilMailMimeTransportSendmail::class, $factory->getTransport());
173 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
177 $mustache_factory = $this->getMockBuilder(ilMustacheFactory::class)->getMock();
180 $this->assertInstanceOf(ilMailMimeSenderSystem::class, $factory->getSenderByUsrId(
ANONYMOUS_USER_ID));
188 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
192 $mustache_factory = $this->getMockBuilder(ilMustacheFactory::class)->getMock();
195 $this->assertInstanceOf(ilMailMimeSenderSystem::class, $factory->system());
203 $user = $this->getMockBuilder(ilObjUser::class)
204 ->disableOriginalConstructor()
205 ->onlyMethods([
'getId'])
207 $user->method(
'getId')->willReturn($usrId);
217 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
221 $mustache_factory = $this->getMockBuilder(ilMustacheFactory::class)->getMock();
224 $this->assertInstanceOf(ilMailMimeSenderUser::class, $factory->getSenderByUsrId(self::USER_ID));
232 $settings = $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->onlyMethods([
236 $mustache_factory = $this->getMockBuilder(ilMustacheFactory::class)->getMock();
239 $this->assertInstanceOf(ilMailMimeSenderUser::class, $factory->user(self::USER_ID));
static addUserToCache(int $usrId, ilObjUser $user)
testFactoryWillReturnUserSenderForExistingUserId()
static setDefaultTransport(?ilMailMimeTransport $transport)
testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled()
testFactoryWillReturnSystemSenderForAnonymousUserId()
testFactoryWillReturnSystemSenderWhenExplicitlyRequested()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setGlobalVariable(string $name, $value)
testMimMailDelegatesEmailDeliveryToDefaultTransport()
testMimMailDelegatesEmailDeliveryToThePassedTransporter()
testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled()
testFactoryWillReturnUserSenderWhenExplicitlyRequested()
testTransportFactoryWillReturnSmtpTransportIfEnabled()