|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2014 Roave, LLC. |
|
4
|
|
|
* All rights reserved. |
|
5
|
|
|
* |
|
6
|
|
|
* Redistribution and use in source and binary forms, with or without |
|
7
|
|
|
* modification, are permitted provided that the following conditions |
|
8
|
|
|
* are met: |
|
9
|
|
|
* |
|
10
|
|
|
* * Redistributions of source code must retain the above copyright |
|
11
|
|
|
* notice, this list of conditions and the following disclaimer. |
|
12
|
|
|
* |
|
13
|
|
|
* * Redistributions in binary form must reproduce the above copyright |
|
14
|
|
|
* notice, this list of conditions and the following disclaimer in |
|
15
|
|
|
* the documentation and/or other materials provided with the |
|
16
|
|
|
* distribution. |
|
17
|
|
|
* |
|
18
|
|
|
* * Neither the names of the copyright holders nor the names of the |
|
19
|
|
|
* contributors may be used to endorse or promote products derived |
|
20
|
|
|
* from this software without specific prior written permission. |
|
21
|
|
|
* |
|
22
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
23
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
24
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
25
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
26
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
27
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
28
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
29
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
30
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
31
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
32
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
33
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
34
|
|
|
* |
|
35
|
|
|
* @author Antoine Hedgecock |
|
36
|
|
|
* @author Jonas Rosenlind |
|
37
|
|
|
* |
|
38
|
|
|
* @copyright 2014 Roave, LLC |
|
39
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
40
|
|
|
*/ |
|
41
|
|
|
|
|
42
|
|
|
namespace EmailTemplatesTest\Factory\Service; |
|
43
|
|
|
|
|
44
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
45
|
|
|
use PHPUnit_Framework_TestCase; |
|
46
|
|
|
use Roave\EmailTemplates\Factory\Service\TemplateServiceFactory; |
|
47
|
|
|
use Roave\EmailTemplates\Hydrator\TemplateHydrator; |
|
48
|
|
|
use Roave\EmailTemplates\InputFilter\TemplateInputFilter; |
|
49
|
|
|
use Roave\EmailTemplates\Options\TemplateServiceOptions; |
|
50
|
|
|
use Roave\EmailTemplates\Repository\TemplateRepository; |
|
51
|
|
|
use Roave\EmailTemplates\Repository\TemplateRepositoryInterface; |
|
52
|
|
|
use Roave\EmailTemplates\Service\Template\EnginePluginManager; |
|
53
|
|
|
use Roave\EmailTemplates\Service\Template\Listener\UpdateTemplateParametersListener; |
|
54
|
|
|
use Roave\EmailTemplates\Service\TemplateService; |
|
55
|
|
|
use Zend\EventManager\ListenerAggregateInterface; |
|
56
|
|
|
use Zend\InputFilter\InputFilterPluginManager; |
|
57
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
58
|
|
|
use Zend\Stdlib\Hydrator\HydratorPluginManager; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Class TemplateServiceFactoryTest |
|
62
|
|
|
* |
|
63
|
|
|
* @coversDefaultClass \Roave\EmailTemplates\Factory\Service\TemplateServiceFactory |
|
64
|
|
|
* @covers ::<!public> |
|
65
|
|
|
*/ |
|
66
|
|
|
class TemplateServiceFactoryTest extends PHPUnit_Framework_TestCase |
|
67
|
|
|
{ |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var TemplateServiceFactory |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $factory; |
|
73
|
|
|
|
|
74
|
|
|
public function setUp() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->factory = new TemplateServiceFactory(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @covers ::createService |
|
81
|
|
|
*/ |
|
82
|
|
|
public function testCreateService() |
|
83
|
|
|
{ |
|
84
|
|
|
$templateRepository = $this->createMock(TemplateRepositoryInterface::class); |
|
85
|
|
|
|
|
86
|
|
|
$inputFilterManager = $this->createMock(InputFilterPluginManager::class); |
|
87
|
|
|
$inputFilterManager |
|
88
|
|
|
->expects($this->once()) |
|
89
|
|
|
->method('get') |
|
90
|
|
|
->with(TemplateInputFilter::class) |
|
91
|
|
|
->will($this->returnValue($this->createMock(TemplateInputFilter::class))); |
|
92
|
|
|
|
|
93
|
|
|
$hydratorManager = $this->createMock(HydratorPluginManager::class); |
|
94
|
|
|
$hydratorManager |
|
95
|
|
|
->expects($this->once()) |
|
96
|
|
|
->method('get') |
|
97
|
|
|
->with(TemplateHydrator::class) |
|
98
|
|
|
->will($this->returnValue($this->createMock(TemplateHydrator::class))); |
|
99
|
|
|
|
|
100
|
|
|
$sl = $this->createMock(ServiceLocatorInterface::class); |
|
101
|
|
|
$sl |
|
102
|
|
|
->expects($this->at(0)) |
|
103
|
|
|
->method('get') |
|
104
|
|
|
->with('Roave\EmailTemplates\ObjectManager') |
|
105
|
|
|
->will($this->returnValue($this->createMock(ObjectManager::class))); |
|
106
|
|
|
|
|
107
|
|
|
$sl |
|
108
|
|
|
->expects($this->at(1)) |
|
109
|
|
|
->method('get') |
|
110
|
|
|
->with(TemplateRepository::class) |
|
111
|
|
|
->will($this->returnValue($templateRepository)); |
|
112
|
|
|
|
|
113
|
|
|
$sl |
|
114
|
|
|
->expects($this->at(2)) |
|
115
|
|
|
->method('get') |
|
116
|
|
|
->with('inputFilterManager') |
|
117
|
|
|
->will($this->returnValue($inputFilterManager)); |
|
118
|
|
|
|
|
119
|
|
|
$sl |
|
120
|
|
|
->expects($this->at(3)) |
|
121
|
|
|
->method('get') |
|
122
|
|
|
->with('hydratorManager') |
|
123
|
|
|
->will($this->returnValue($hydratorManager)); |
|
124
|
|
|
|
|
125
|
|
|
$sl |
|
126
|
|
|
->expects($this->at(4)) |
|
127
|
|
|
->method('get') |
|
128
|
|
|
->with(EnginePluginManager::class) |
|
129
|
|
|
->will($this->returnValue($this->createMock(EnginePluginManager::class))); |
|
130
|
|
|
|
|
131
|
|
|
$sl |
|
132
|
|
|
->expects($this->at(5)) |
|
133
|
|
|
->method('get') |
|
134
|
|
|
->with(TemplateServiceOptions::class) |
|
135
|
|
|
->will($this->returnValue($this->createMock(TemplateServiceOptions::class))); |
|
136
|
|
|
|
|
137
|
|
|
$sl |
|
138
|
|
|
->expects($this->at(6)) |
|
139
|
|
|
->method('get') |
|
140
|
|
|
->with(UpdateTemplateParametersListener::class) |
|
141
|
|
|
->will($this->returnValue($this->createMock(ListenerAggregateInterface::class))); |
|
142
|
|
|
|
|
143
|
|
|
$service = $this->factory->createService($sl); |
|
144
|
|
|
|
|
145
|
|
|
$this->assertInstanceOf(TemplateService::class, $service); |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|