From ca67e3111c755be8448d43878e65f7238489bdc2 Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Sat, 1 Feb 2020 23:42:56 +0100 Subject: [PATCH] Set sender data directly --- src/Util/EMailer/SystemMailBuilder.php | 4 +- .../Util/Emailer/SystemMailBuilderTest.php | 58 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/src/Util/Emailer/SystemMailBuilderTest.php diff --git a/src/Util/EMailer/SystemMailBuilder.php b/src/Util/EMailer/SystemMailBuilder.php index 93e5cc349f..07cbca4e27 100644 --- a/src/Util/EMailer/SystemMailBuilder.php +++ b/src/Util/EMailer/SystemMailBuilder.php @@ -37,7 +37,9 @@ class SystemMailBuilder extends MailBuilder } // Set the system wide site address/name as sender (default for system mails) - $this->withSender($siteEmailAddress, $siteName); + $this->senderName = $siteName; + $this->senderAddress = $siteEmailAddress; + $this->senderNoReply = $siteEmailAddress; } /** diff --git a/tests/src/Util/Emailer/SystemMailBuilderTest.php b/tests/src/Util/Emailer/SystemMailBuilderTest.php new file mode 100644 index 0000000000..5c531bf3cd --- /dev/null +++ b/tests/src/Util/Emailer/SystemMailBuilderTest.php @@ -0,0 +1,58 @@ +setUpVfsDir(); + + $this->config = \Mockery::mock(IConfig::class); + $this->config->shouldReceive('get')->with('config', 'admin_name')->andReturn('Admin'); + $this->l10n = \Mockery::mock(L10n::class); + $this->l10n->shouldReceive('t')->andReturnUsing(function ($msg) { + return $msg; + }); + $this->baseUrl = \Mockery::mock(BaseURL::class); + $this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local'); + $this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local'); + + $this->defaultHeaders = ""; + } + + /** + * Test if the builder instance can get created + */ + public function testBuilderInstance() + { + $builder = new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, 'moreply@friendica.local', 'FriendicaSite'); + + $this->assertInstanceOf(MailBuilder::class, $builder); + $this->assertInstanceOf(SystemMailBuilder::class, $builder); + } +}