1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MtMail - e-mail module for Zend Framework |
4
|
|
|
* |
5
|
|
|
* @link http://github.com/mtymek/MtMail |
6
|
|
|
* @copyright Copyright (c) 2013-2017 Mateusz Tymek |
7
|
|
|
* @license BSD 2-Clause |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace MtMailTest\Factory; |
11
|
|
|
|
12
|
|
|
use Interop\Container\ContainerInterface; |
13
|
|
|
use MtMail\Factory\SenderServiceFactory; |
14
|
|
|
use MtMail\SenderPlugin\PluginInterface; |
15
|
|
|
use MtMail\Service\Sender; |
16
|
|
|
use MtMail\Service\SenderPluginManager; |
17
|
|
|
use Zend\Mail\Transport\TransportInterface; |
18
|
|
|
|
19
|
|
|
class SenderServiceFactoryTest extends \PHPUnit\Framework\TestCase |
20
|
|
|
{ |
21
|
|
|
public function testCreateService() |
22
|
|
|
{ |
23
|
|
|
$serviceLocator = $this->prophesize(ContainerInterface::class); |
24
|
|
|
|
25
|
|
|
$serviceLocator->get('Configuration') |
26
|
|
|
->willReturn( |
27
|
|
|
[ |
28
|
|
|
'mt_mail' => [ |
29
|
|
|
'sender_plugins' => ['DefaultHeaders', 'DefaultHeaders'], 'transport' => 'transport.file' |
30
|
|
|
] |
31
|
|
|
] |
32
|
|
|
); |
33
|
|
|
|
34
|
|
|
$transport = $this->prophesize(TransportInterface::class); |
35
|
|
|
$serviceLocator->get('transport.file') |
36
|
|
|
->willReturn($transport); |
37
|
|
|
|
38
|
|
|
$pluginManager = $this->prophesize(ContainerInterface::class); |
39
|
|
|
|
40
|
|
|
$serviceLocator->get(SenderPluginManager::class) |
41
|
|
|
->willReturn($pluginManager->reveal()); |
42
|
|
|
|
43
|
|
|
$plugin = $this->prophesize(PluginInterface::class); |
44
|
|
|
|
45
|
|
|
$pluginManager->get('DefaultHeaders') |
46
|
|
|
->willReturn($plugin->reveal()); |
47
|
|
|
|
48
|
|
|
$factory = new SenderServiceFactory; |
49
|
|
|
|
50
|
|
|
$this->assertInstanceOf(Sender::class, $factory($serviceLocator->reveal())); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|