45466bb8aec6deb45387066cc1990923605d8423
[friendica.git/.git] / tests / src / Util / Emailer / SystemMailBuilderTest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Util\Emailer;
23
24 use Friendica\App\BaseURL;
25 use Friendica\Core\Config\IConfig;
26 use Friendica\Core\L10n;
27 use Friendica\Test\MockedTest;
28 use Friendica\Test\Util\VFSTrait;
29 use Friendica\Util\EMailer\MailBuilder;
30 use Friendica\Util\EMailer\SystemMailBuilder;
31 use Psr\Log\NullLogger;
32
33 class SystemMailBuilderTest extends MockedTest
34 {
35         use VFSTrait;
36
37         /** @var IConfig */
38         private $config;
39         /** @var L10n */
40         private $l10n;
41         /** @var BaseURL */
42         private $baseUrl;
43
44         /** @var string */
45         private $defaultHeaders;
46
47         public function setUp()
48         {
49                 parent::setUp();
50
51                 $this->setUpVfsDir();
52
53                 $this->config  = \Mockery::mock(IConfig::class);
54                 $this->config->shouldReceive('get')->with('config', 'admin_name')->andReturn('Admin');
55                 $this->l10n    = \Mockery::mock(L10n::class);
56                 $this->l10n->shouldReceive('t')->andReturnUsing(function ($msg) {
57                         return $msg;
58                 });
59                 $this->baseUrl = \Mockery::mock(BaseURL::class);
60                 $this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');
61                 $this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
62
63                 $this->defaultHeaders = "";
64         }
65
66         /**
67          * Test if the builder instance can get created
68          */
69         public function testBuilderInstance()
70         {
71                 $builder = new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config, new NullLogger(), 'moreply@friendica.local', 'FriendicaSite');
72
73                 $this->assertInstanceOf(MailBuilder::class, $builder);
74                 $this->assertInstanceOf(SystemMailBuilder::class, $builder);
75         }
76 }