friendica/tests/src/Util/Emailer/SystemMailBuilderTest.php

77 lines
2.2 KiB
PHP
Raw Normal View History

2020-02-01 23:42:56 +01:00
<?php
2020-02-09 15:45:36 +01:00
/**
* @copyright Copyright (C) 2020, Friendica
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
2020-02-01 23:42:56 +01:00
namespace Friendica\Test\src\Util\Emailer;
use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\EMailer\MailBuilder;
use Friendica\Util\EMailer\SystemMailBuilder;
2020-02-04 21:32:18 +01:00
use Psr\Log\NullLogger;
2020-02-01 23:42:56 +01:00
class SystemMailBuilderTest extends MockedTest
{
use VFSTrait;
/** @var IConfig */
private $config;
/** @var L10n */
private $l10n;
/** @var BaseURL */
private $baseUrl;
/** @var string[] */
2020-02-01 23:42:56 +01:00
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 = [];
2020-02-01 23:42:56 +01:00
}
/**
* Test if the builder instance can get created
*/
public function testBuilderInstance()
{
2020-02-04 21:32:18 +01:00
$builder = new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger(), 'moreply@friendica.local', 'FriendicaSite');
2020-02-01 23:42:56 +01:00
$this->assertInstanceOf(MailBuilder::class, $builder);
$this->assertInstanceOf(SystemMailBuilder::class, $builder);
}
}