18
18
* SOFTWARE.
19
19
*/
20
20
21
+ declare (strict_types=1 );
22
+
21
23
namespace DarkWebDesign \SymfonyAddonTransformers \Tests ;
22
24
23
25
use DarkWebDesign \SymfonyAddonTransformers \EntityToIdentifierTransformer ;
@@ -43,13 +45,13 @@ class EntityToIdentifierTransformerTest extends TestCase
43
45
/** @var int */
44
46
private $ identifier ;
45
47
46
- /** @var \Doctrine\Common\Persistence\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */
48
+ /** @var \Doctrine\Common\Persistence\ObjectManager|\PHPUnit\Framework\MockObject\MockObject */
47
49
private $ entityManager ;
48
50
49
- /** @var \Doctrine\Common\Persistence\ObjectRepository|\PHPUnit_Framework_MockObject_MockObject */
51
+ /** @var \Doctrine\Common\Persistence\ObjectRepository|\PHPUnit\Framework\MockObject\MockObject */
50
52
private $ repository ;
51
53
52
- /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata|\PHPUnit_Framework_MockObject_MockObject */
54
+ /** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata|\PHPUnit\Framework\MockObject\MockObject */
53
55
private $ metadata ;
54
56
55
57
protected function setUp (): void
@@ -73,23 +75,17 @@ protected function setUp(): void
73
75
$ this ->metadata ->isIdentifierComposite = false ;
74
76
}
75
77
76
- /**
77
- * @return string
78
- */
79
- public function getClassName ()
78
+ public function getClassName (): string
80
79
{
81
80
return $ this ->className ;
82
81
}
83
82
84
- /**
85
- * @return array
86
- */
87
- public function getIdentifier ()
83
+ public function getIdentifier (): array
88
84
{
89
85
return ['id ' => $ this ->identifier ];
90
86
}
91
87
92
- public function testConstructIdentifierComposite ()
88
+ public function testConstructIdentifierComposite (): void
93
89
{
94
90
$ this ->expectException (InvalidArgumentException::class);
95
91
$ this ->expectExceptionMessage ('Expected an entity with a single identifier. ' );
@@ -99,7 +95,7 @@ public function testConstructIdentifierComposite()
99
95
new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
100
96
}
101
97
102
- public function testTransform ()
98
+ public function testTransform (): void
103
99
{
104
100
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
105
101
@@ -108,7 +104,7 @@ public function testTransform()
108
104
$ this ->assertSame ($ this ->identifier , $ identifier );
109
105
}
110
106
111
- public function testTransformAlias ()
107
+ public function testTransformAlias (): void
112
108
{
113
109
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , 'AppBundle:City ' );
114
110
@@ -117,7 +113,7 @@ public function testTransformAlias()
117
113
$ this ->assertSame ($ this ->identifier , $ identifier );
118
114
}
119
115
120
- public function testTransformDiscriminated ()
116
+ public function testTransformDiscriminated (): void
121
117
{
122
118
$ this ->className = AbstractPerson::class;
123
119
@@ -130,7 +126,7 @@ public function testTransformDiscriminated()
130
126
$ this ->assertSame ($ this ->identifier , $ identifier );
131
127
}
132
128
133
- public function testTransformNull ()
129
+ public function testTransformNull (): void
134
130
{
135
131
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
136
132
@@ -144,7 +140,7 @@ public function testTransformNull()
144
140
*
145
141
* @dataProvider providerNoObject
146
142
*/
147
- public function testTransformNoObject ($ value )
143
+ public function testTransformNoObject ($ value ): void
148
144
{
149
145
$ this ->expectException (TransformationFailedException::class);
150
146
$ this ->expectExceptionMessage ('Expected an object. ' );
@@ -154,7 +150,7 @@ public function testTransformNoObject($value)
154
150
$ transformer ->transform ($ value );
155
151
}
156
152
157
- public function testTransformInvalidEntity ()
153
+ public function testTransformInvalidEntity (): void
158
154
{
159
155
$ this ->expectException (TransformationFailedException::class);
160
156
$ this ->expectExceptionMessage ('Expected entity DarkWebDesign\SymfonyAddonTransformers\Tests\Models\City. ' );
@@ -166,7 +162,7 @@ public function testTransformInvalidEntity()
166
162
$ transformer ->transform ($ entity );
167
163
}
168
164
169
- public function testReverseTransform ()
165
+ public function testReverseTransform (): void
170
166
{
171
167
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
172
168
@@ -177,7 +173,7 @@ public function testReverseTransform()
177
173
$ this ->assertSame ($ this ->identifier , $ entity ->getId ());
178
174
}
179
175
180
- public function testReverseTransformNull ()
176
+ public function testReverseTransformNull (): void
181
177
{
182
178
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
183
179
@@ -186,7 +182,7 @@ public function testReverseTransformNull()
186
182
$ this ->assertNull ($ entity );
187
183
}
188
184
189
- public function testReverseTransformEmptyString ()
185
+ public function testReverseTransformEmptyString (): void
190
186
{
191
187
$ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ this ->className );
192
188
@@ -200,7 +196,7 @@ public function testReverseTransformEmptyString()
200
196
*
201
197
* @dataProvider providerNoScalar
202
198
*/
203
- public function testReverseTransformNoScalar ($ value )
199
+ public function testReverseTransformNoScalar ($ value ): void
204
200
{
205
201
$ this ->expectException (TransformationFailedException::class);
206
202
$ this ->expectExceptionMessage ('Expected a scalar. ' );
@@ -210,7 +206,7 @@ public function testReverseTransformNoScalar($value)
210
206
$ transformer ->reverseTransform ($ value );
211
207
}
212
208
213
- public function testReverseTransformEntityNotFound ()
209
+ public function testReverseTransformEntityNotFound (): void
214
210
{
215
211
$ this ->expectException (TransformationFailedException::class);
216
212
$ this ->expectExceptionMessage ('Entity DarkWebDesign\SymfonyAddonTransformers\Tests\Models\City with identifier "123" not found. ' );
@@ -222,10 +218,7 @@ public function testReverseTransformEntityNotFound()
222
218
$ transformer ->reverseTransform ($ this ->identifier );
223
219
}
224
220
225
- /**
226
- * @return array[]
227
- */
228
- public function providerNoObject ()
221
+ public function providerNoObject (): array
229
222
{
230
223
return [
231
224
'bool ' => [true ],
@@ -238,10 +231,7 @@ public function providerNoObject()
238
231
];
239
232
}
240
233
241
- /**
242
- * @return array[]
243
- */
244
- public function providerNoScalar ()
234
+ public function providerNoScalar (): array
245
235
{
246
236
return [
247
237
'array ' => [['foo ' , 'bar ' ]],
0 commit comments