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\Entity; |
43
|
|
|
|
44
|
|
|
use DateTime; |
45
|
|
|
use PHPUnit_Framework_TestCase; |
46
|
|
|
use Roave\EmailTemplates\Entity\TemplateEntity; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Class TemplateEntityTest |
50
|
|
|
* |
51
|
|
|
* @coversDefaultClass \Roave\EmailTemplates\Entity\TemplateEntity |
52
|
|
|
* @covers ::<!public> |
53
|
|
|
* |
54
|
|
|
* @group entity |
55
|
|
|
*/ |
56
|
|
|
class TemplateEntityTest extends PHPUnit_Framework_TestCase |
57
|
|
|
{ |
58
|
|
|
/** |
59
|
|
|
* @var TemplateEntity |
60
|
|
|
*/ |
61
|
|
|
private $template; |
62
|
|
|
|
63
|
|
|
protected function setUp() |
64
|
|
|
{ |
65
|
|
|
$this->template = new TemplateEntity(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @covers ::setId |
70
|
|
|
* @covers ::getId |
71
|
|
|
*/ |
72
|
|
|
public function testSetGetId() |
73
|
|
|
{ |
74
|
|
|
$this->assertEmpty($this->template->getId()); |
75
|
|
|
$this->template->setId(1); |
76
|
|
|
$this->assertEquals(1, $this->template->getId()); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @covers ::setUuid |
81
|
|
|
* @covers ::getUuid |
82
|
|
|
*/ |
83
|
|
|
public function testSetGetUuid() |
84
|
|
|
{ |
85
|
|
|
$this->assertEmpty($this->template->getUuid()); |
86
|
|
|
$this->template->setUuid(1); |
87
|
|
|
$this->assertEquals(1, $this->template->getUuid()); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @covers ::setLocale |
92
|
|
|
* @covers ::getLocale |
93
|
|
|
*/ |
94
|
|
|
public function testSetGetLocale() |
95
|
|
|
{ |
96
|
|
|
$this->assertEmpty($this->template->getLocale()); |
97
|
|
|
$this->template->setLocale('en-US'); |
98
|
|
|
$this->assertEquals('en-US', $this->template->getLocale()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @covers ::getTextBody |
103
|
|
|
* @covers ::setTextBody |
104
|
|
|
*/ |
105
|
|
|
public function testSetGetTextBody() |
106
|
|
|
{ |
107
|
|
|
$this->assertEmpty($this->template->getTextBody()); |
108
|
|
|
$this->template->setTextBody('Foobar'); |
109
|
|
|
$this->assertEquals('Foobar', $this->template->getTextBody()); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @covers ::getHtmlBody |
114
|
|
|
* @covers ::setHtmlBody |
115
|
|
|
*/ |
116
|
|
|
public function testSetGetHtmlBody() |
117
|
|
|
{ |
118
|
|
|
$this->assertEmpty($this->template->getHtmlBody()); |
119
|
|
|
$this->template->setHtmlBody('f00bar'); |
120
|
|
|
$this->assertEquals('f00bar', $this->template->getHtmlBody()); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @covers ::setParameters |
125
|
|
|
* @covers ::getParameters |
126
|
|
|
*/ |
127
|
|
|
public function testSetGetParameters() |
128
|
|
|
{ |
129
|
|
|
$this->assertEmpty($this->template->getParameters()); |
130
|
|
|
$this->template->setParameters(['foo' => 'bar']); |
131
|
|
|
$this->assertEquals(['foo' => 'bar'], $this->template->getParameters()); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @covers ::getSubject |
136
|
|
|
* @covers ::setSubject |
137
|
|
|
*/ |
138
|
|
|
public function testSetGetSubject() |
139
|
|
|
{ |
140
|
|
|
$this->assertEmpty($this->template->getSubject()); |
141
|
|
|
$this->template->setSubject('Foobar'); |
142
|
|
|
$this->assertEquals('Foobar', $this->template->getSubject()); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @covers ::getDescription |
147
|
|
|
* @covers ::setDescription |
148
|
|
|
*/ |
149
|
|
|
public function testSetGetDescription() |
150
|
|
|
{ |
151
|
|
|
$this->assertEmpty($this->template->getDescription()); |
152
|
|
|
$this->template->setDescription('bar'); |
153
|
|
|
$this->assertEquals('bar', $this->template->getDescription()); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @covers ::setParametersUpdatedAt |
158
|
|
|
* @covers ::getParametersUpdatedAt |
159
|
|
|
*/ |
160
|
|
|
public function testSetGetParamsUpdatedAt() |
161
|
|
|
{ |
162
|
|
|
$date = new DateTime(); |
163
|
|
|
$this->assertNull($this->template->getParametersUpdatedAt()); |
164
|
|
|
$this->template->setParametersUpdatedAt($date); |
165
|
|
|
$this->assertEquals($date, $this->template->getParametersUpdatedAt()); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @covers ::setUpdateParameters |
170
|
|
|
* @covers ::getUpdateParameters |
171
|
|
|
*/ |
172
|
|
|
public function testSetGetUpdateParameters() |
173
|
|
|
{ |
174
|
|
|
$this->assertFalse($this->template->getUpdateParameters()); |
175
|
|
|
$this->template->setUpdateParameters(true); |
176
|
|
|
$this->assertEquals(true, $this->template->getUpdateParameters()); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @covers ::getCreatedAt |
181
|
|
|
* @covers ::setCreatedAt |
182
|
|
|
*/ |
183
|
|
|
public function testSetGetCreatedAt() |
184
|
|
|
{ |
185
|
|
|
$date = new DateTime(); |
186
|
|
|
$this->assertNull($this->template->getCreatedAt()); |
187
|
|
|
$this->template->setCreatedAt($date); |
188
|
|
|
$this->assertEquals($date, $this->template->getCreatedAt()); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @covers ::getUpdatedAt |
193
|
|
|
* @covers ::setUpdatedAt |
194
|
|
|
*/ |
195
|
|
|
public function testSetGetUpdatedAt() |
196
|
|
|
{ |
197
|
|
|
$date = new DateTime(); |
198
|
|
|
$this->assertNull($this->template->getUpdatedAt()); |
199
|
|
|
$this->template->setUpdatedAt($date); |
200
|
|
|
$this->assertEquals($date, $this->template->getUpdatedAt()); |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|