Set sender data directly

This commit is contained in:
nupplaPhil 2020-02-01 23:42:56 +01:00
parent 97e708f2e2
commit ca67e3111c
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
2 changed files with 61 additions and 1 deletions

View file

@ -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;
}
/**

View file

@ -0,0 +1,58 @@
<?php
namespace Friendica\Test\src\Util\Emailer;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Object\EMail\IEmail;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\SampleMailBuilder;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\EMailer\MailBuilder;
use Friendica\Util\EMailer\SystemMailBuilder;
class SystemMailBuilderTest extends MockedTest
{
use VFSTrait;
/** @var IConfig */
private $config;
/** @var L10n */
private $l10n;
/** @var BaseURL */
private $baseUrl;
/** @var string */
private $defaultHeaders;
public function setUp()
{
parent::setUp();
$this->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);
}
}