1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace HelloWordPl\SimpleEntityGeneratorBundle\Tests\Lib; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\ClassConstructorManager; |
7
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\ClassManager; |
8
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\Items\InitPropertyManager; |
9
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
10
|
|
|
use HelloWordPl\SimpleEntityGeneratorBundle\Lib\ClassConfig; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Renderer Test |
14
|
|
|
* |
15
|
|
|
* @author Sławomir Kania <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class RendererTest extends KernelTestCase |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
protected $postClassWithUpdatedConstructor = <<<EOT |
24
|
|
|
<?php |
25
|
|
|
|
26
|
|
|
namespace AppBundle\Entity; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
* |
31
|
|
|
*/ |
32
|
|
|
class Post implements \AppBundle\Entity\PostInterface |
33
|
|
|
{ |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Post content |
37
|
|
|
* |
38
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank() |
39
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
40
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("content") |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private \$content; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* 'created_at' property |
47
|
|
|
* |
48
|
|
|
* |
49
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
50
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("created_at") |
51
|
|
|
* @var \DateTime |
52
|
|
|
*/ |
53
|
|
|
private \$createdAt; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* 'updated_at' property |
57
|
|
|
* |
58
|
|
|
* |
59
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
60
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("updated_at") |
61
|
|
|
* @var \DateTime |
62
|
|
|
*/ |
63
|
|
|
private \$updatedAt; |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Constructor. |
68
|
|
|
*/ |
69
|
|
|
public function __construct() |
70
|
|
|
{ |
71
|
|
|
\$this->collection = new \Doctrine\Common\Collections\ArrayCollection(); |
72
|
|
|
\$this->collection2 = new \Doctrine\Common\Collections\ArrayCollection(); |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* For property "content" |
79
|
|
|
* @param string \$content |
80
|
|
|
* @return \$this |
81
|
|
|
*/ |
82
|
|
|
public function setContent(\$content) |
83
|
|
|
{ |
84
|
|
|
\$this->content = \$content; |
85
|
|
|
return \$this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* For property "content" |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
public function getContent() |
93
|
|
|
{ |
94
|
|
|
return \$this->content; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* For property "createdAt" |
99
|
|
|
* @param \DateTime \$createdAt |
100
|
|
|
* @return \$this |
101
|
|
|
*/ |
102
|
|
|
public function setCreatedAt(\DateTime \$createdAt) |
103
|
|
|
{ |
104
|
|
|
\$this->createdAt = \$createdAt; |
105
|
|
|
return \$this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* For property "createdAt" |
110
|
|
|
* @return \DateTime |
111
|
|
|
*/ |
112
|
|
|
public function getCreatedAt() |
113
|
|
|
{ |
114
|
|
|
return \$this->createdAt; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* For property "updatedAt" |
119
|
|
|
* @param \DateTime \$updatedAt |
120
|
|
|
* @return \$this |
121
|
|
|
*/ |
122
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt) |
123
|
|
|
{ |
124
|
|
|
\$this->updatedAt = \$updatedAt; |
125
|
|
|
return \$this; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* For property "updatedAt" |
130
|
|
|
* @return \DateTime |
131
|
|
|
*/ |
132
|
|
|
public function getUpdatedAt() |
133
|
|
|
{ |
134
|
|
|
return \$this->updatedAt; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
EOT; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @var string |
143
|
|
|
*/ |
144
|
|
|
protected $postClassWithNewPropertyExpected = <<<EOT |
145
|
|
|
<?php |
146
|
|
|
|
147
|
|
|
namespace AppBundle\Entity; |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* |
151
|
|
|
* |
152
|
|
|
*/ |
153
|
|
|
class Post implements \AppBundle\Entity\PostInterface |
154
|
|
|
{ |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Post content |
158
|
|
|
* |
159
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank() |
160
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
161
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("content") |
162
|
|
|
* @var string |
163
|
|
|
*/ |
164
|
|
|
private \$content; |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* 'created_at' property |
168
|
|
|
* |
169
|
|
|
* |
170
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
171
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("created_at") |
172
|
|
|
* @var \DateTime |
173
|
|
|
*/ |
174
|
|
|
private \$createdAt; |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* 'updated_at' property |
178
|
|
|
* |
179
|
|
|
* |
180
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
181
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("updated_at") |
182
|
|
|
* @var \DateTime |
183
|
|
|
*/ |
184
|
|
|
private \$updatedAt; |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* is post active |
188
|
|
|
* |
189
|
|
|
* @\Symfony\Component\Validator\Constraints\IsTrue() |
190
|
|
|
* @\JMS\Serializer\Annotation\Type("boolean") |
191
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("active") |
192
|
|
|
* @var boolean |
193
|
|
|
*/ |
194
|
|
|
private \$active; |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Constructor. |
199
|
|
|
*/ |
200
|
|
|
public function __construct() |
201
|
|
|
{ |
202
|
|
|
|
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* For property "content" |
208
|
|
|
* @param string \$content |
209
|
|
|
* @return \$this |
210
|
|
|
*/ |
211
|
|
|
public function setContent(\$content) |
212
|
|
|
{ |
213
|
|
|
\$this->content = \$content; |
214
|
|
|
return \$this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* For property "content" |
219
|
|
|
* @return string |
220
|
|
|
*/ |
221
|
|
|
public function getContent() |
222
|
|
|
{ |
223
|
|
|
return \$this->content; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* For property "createdAt" |
228
|
|
|
* @param \DateTime \$createdAt |
229
|
|
|
* @return \$this |
230
|
|
|
*/ |
231
|
|
|
public function setCreatedAt(\DateTime \$createdAt) |
232
|
|
|
{ |
233
|
|
|
\$this->createdAt = \$createdAt; |
234
|
|
|
return \$this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* For property "createdAt" |
239
|
|
|
* @return \DateTime |
240
|
|
|
*/ |
241
|
|
|
public function getCreatedAt() |
242
|
|
|
{ |
243
|
|
|
return \$this->createdAt; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* For property "updatedAt" |
248
|
|
|
* @param \DateTime \$updatedAt |
249
|
|
|
* @return \$this |
250
|
|
|
*/ |
251
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt) |
252
|
|
|
{ |
253
|
|
|
\$this->updatedAt = \$updatedAt; |
254
|
|
|
return \$this; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* For property "updatedAt" |
259
|
|
|
* @return \DateTime |
260
|
|
|
*/ |
261
|
|
|
public function getUpdatedAt() |
262
|
|
|
{ |
263
|
|
|
return \$this->updatedAt; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
EOT; |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* @var string |
272
|
|
|
*/ |
273
|
|
|
protected $postClassExpected = <<<EOT |
274
|
|
|
<?php |
275
|
|
|
|
276
|
|
|
namespace AppBundle\Entity; |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* |
280
|
|
|
* |
281
|
|
|
*/ |
282
|
|
|
class Post implements \AppBundle\Entity\PostInterface |
283
|
|
|
{ |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* Post content |
287
|
|
|
* |
288
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank() |
289
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
290
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("content") |
291
|
|
|
* @var string |
292
|
|
|
*/ |
293
|
|
|
private \$content; |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* 'created_at' property |
297
|
|
|
* |
298
|
|
|
* |
299
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
300
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("created_at") |
301
|
|
|
* @var \DateTime |
302
|
|
|
*/ |
303
|
|
|
private \$createdAt; |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* 'updated_at' property |
307
|
|
|
* |
308
|
|
|
* |
309
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
310
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("updated_at") |
311
|
|
|
* @var \DateTime |
312
|
|
|
*/ |
313
|
|
|
private \$updatedAt; |
314
|
|
|
|
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Constructor. |
318
|
|
|
*/ |
319
|
|
|
public function __construct() |
320
|
|
|
{ |
321
|
|
|
|
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* For property "content" |
327
|
|
|
* @param string \$content |
328
|
|
|
* @return \$this |
329
|
|
|
*/ |
330
|
|
|
public function setContent(\$content) |
331
|
|
|
{ |
332
|
|
|
\$this->content = \$content; |
333
|
|
|
return \$this; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* For property "content" |
338
|
|
|
* @return string |
339
|
|
|
*/ |
340
|
|
|
public function getContent() |
341
|
|
|
{ |
342
|
|
|
return \$this->content; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* For property "createdAt" |
347
|
|
|
* @param \DateTime \$createdAt |
348
|
|
|
* @return \$this |
349
|
|
|
*/ |
350
|
|
|
public function setCreatedAt(\DateTime \$createdAt) |
351
|
|
|
{ |
352
|
|
|
\$this->createdAt = \$createdAt; |
353
|
|
|
return \$this; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* For property "createdAt" |
358
|
|
|
* @return \DateTime |
359
|
|
|
*/ |
360
|
|
|
public function getCreatedAt() |
361
|
|
|
{ |
362
|
|
|
return \$this->createdAt; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* For property "updatedAt" |
367
|
|
|
* @param \DateTime \$updatedAt |
368
|
|
|
* @return \$this |
369
|
|
|
*/ |
370
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt) |
371
|
|
|
{ |
372
|
|
|
\$this->updatedAt = \$updatedAt; |
373
|
|
|
return \$this; |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* For property "updatedAt" |
378
|
|
|
* @return \DateTime |
379
|
|
|
*/ |
380
|
|
|
public function getUpdatedAt() |
381
|
|
|
{ |
382
|
|
|
return \$this->updatedAt; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
EOT; |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* @var string |
391
|
|
|
*/ |
392
|
|
|
protected $userClassExpected = <<<EOT |
393
|
|
|
<?php |
394
|
|
|
|
395
|
|
|
namespace AppBundle\Entity; |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* New User entity |
399
|
|
|
* lorem ipsum |
400
|
|
|
* second row |
401
|
|
|
* @\Doctrine\Common\Annotations\Entity() |
402
|
|
|
*/ |
403
|
|
|
class User extends \AppBundle\Entity\Base implements \AppBundle\Entity\UserInterface |
404
|
|
|
{ |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Username for login |
408
|
|
|
* |
409
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank(message = "Login can not be empty") |
410
|
|
|
* @\Symfony\Component\Validator\Constraints\NotNull(message = "Login can not be null") |
411
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
412
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("username") |
413
|
|
|
* @var string |
414
|
|
|
*/ |
415
|
|
|
private \$username; |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* User email |
419
|
|
|
* @\Doctrine\Common\Annotations\Column() |
420
|
|
|
* lorem ipsum |
421
|
|
|
* third row |
422
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank() |
423
|
|
|
* @\Symfony\Component\Validator\Constraints\Email(message = "Invalid email") |
424
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
425
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("email") |
426
|
|
|
* @var string |
427
|
|
|
*/ |
428
|
|
|
private \$email; |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* Wether user is active or not |
432
|
|
|
* |
433
|
|
|
* @\Symfony\Component\Validator\Constraints\IsTrue() |
434
|
|
|
* @\JMS\Serializer\Annotation\Type("boolean") |
435
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("active") |
436
|
|
|
* @var boolean |
437
|
|
|
*/ |
438
|
|
|
private \$active; |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* User posts |
442
|
|
|
* |
443
|
|
|
* |
444
|
|
|
* @\JMS\Serializer\Annotation\Type("Doctrine\Common\Collections\ArrayCollection<AppBundle\Entity\Post>") |
445
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("posts") |
446
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
447
|
|
|
*/ |
448
|
|
|
private \$posts; |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* 'created_at' property |
452
|
|
|
* |
453
|
|
|
* |
454
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
455
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("created_at") |
456
|
|
|
* @var \DateTime |
457
|
|
|
*/ |
458
|
|
|
private \$createdAt; |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* 'updated_at' property |
462
|
|
|
* |
463
|
|
|
* |
464
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
465
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("updated_at") |
466
|
|
|
* @var \DateTime |
467
|
|
|
*/ |
468
|
|
|
private \$updatedAt; |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* 'last_post' property |
472
|
|
|
* |
473
|
|
|
* |
474
|
|
|
* @\JMS\Serializer\Annotation\Type("AppBundle\Entity\Post") |
475
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("lastPost") |
476
|
|
|
* @var \AppBundle\Entity\Post |
477
|
|
|
*/ |
478
|
|
|
private \$lastPost; |
479
|
|
|
|
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* Constructor. |
483
|
|
|
*/ |
484
|
|
|
public function __construct() |
485
|
|
|
{ |
486
|
|
|
\$this->posts = new \Doctrine\Common\Collections\ArrayCollection(); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* For property "username" |
492
|
|
|
* @param string \$username |
493
|
|
|
* @return \$this |
494
|
|
|
*/ |
495
|
|
|
public function setUsername(\$username) |
496
|
|
|
{ |
497
|
|
|
\$this->username = \$username; |
498
|
|
|
return \$this; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
/** |
502
|
|
|
* For property "username" |
503
|
|
|
* @return string |
504
|
|
|
*/ |
505
|
|
|
public function getUsername() |
506
|
|
|
{ |
507
|
|
|
return \$this->username; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
/** |
511
|
|
|
* For property "email" |
512
|
|
|
* @param string \$email |
513
|
|
|
* @return \$this |
514
|
|
|
*/ |
515
|
|
|
public function setEmail(\$email) |
516
|
|
|
{ |
517
|
|
|
\$this->email = \$email; |
518
|
|
|
return \$this; |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* For property "email" |
523
|
|
|
* @return string |
524
|
|
|
*/ |
525
|
|
|
public function getEmail() |
526
|
|
|
{ |
527
|
|
|
return \$this->email; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* For property "active" |
532
|
|
|
* @return boolean |
533
|
|
|
*/ |
534
|
|
|
public function isActive() |
535
|
|
|
{ |
536
|
|
|
return (bool) \$this->active; |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* For property "active" |
541
|
|
|
* @param boolean \$active |
542
|
|
|
* @return \$this |
543
|
|
|
*/ |
544
|
|
|
public function setActive(\$active) |
545
|
|
|
{ |
546
|
|
|
\$this->active = \$active; |
547
|
|
|
return \$this; |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/** |
551
|
|
|
* For property "active" |
552
|
|
|
* @return boolean |
553
|
|
|
*/ |
554
|
|
|
public function getActive() |
555
|
|
|
{ |
556
|
|
|
return \$this->active; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* For property "posts" |
561
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection \$posts |
562
|
|
|
* @return \$this |
563
|
|
|
*/ |
564
|
|
|
public function setPosts(\Doctrine\Common\Collections\ArrayCollection \$posts) |
565
|
|
|
{ |
566
|
|
|
\$this->posts = \$posts; |
567
|
|
|
return \$this; |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* For property "posts" |
572
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
573
|
|
|
*/ |
574
|
|
|
public function getPosts() |
575
|
|
|
{ |
576
|
|
|
return \$this->posts; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* For property "createdAt" |
581
|
|
|
* @param \DateTime \$createdAt |
582
|
|
|
* @return \$this |
583
|
|
|
*/ |
584
|
|
|
public function setCreatedAt(\DateTime \$createdAt) |
585
|
|
|
{ |
586
|
|
|
\$this->createdAt = \$createdAt; |
587
|
|
|
return \$this; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* For property "createdAt" |
592
|
|
|
* @return \DateTime |
593
|
|
|
*/ |
594
|
|
|
public function getCreatedAt() |
595
|
|
|
{ |
596
|
|
|
return \$this->createdAt; |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* For property "updatedAt" |
601
|
|
|
* @param \DateTime \$updatedAt |
602
|
|
|
* @return \$this |
603
|
|
|
*/ |
604
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt) |
605
|
|
|
{ |
606
|
|
|
\$this->updatedAt = \$updatedAt; |
607
|
|
|
return \$this; |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* For property "updatedAt" |
612
|
|
|
* @return \DateTime |
613
|
|
|
*/ |
614
|
|
|
public function getUpdatedAt() |
615
|
|
|
{ |
616
|
|
|
return \$this->updatedAt; |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
/** |
620
|
|
|
* For property "lastPost" |
621
|
|
|
* @param \AppBundle\Entity\Post \$lastPost |
622
|
|
|
* @return \$this |
623
|
|
|
*/ |
624
|
|
|
public function setLastPost(\AppBundle\Entity\Post \$lastPost = null) |
625
|
|
|
{ |
626
|
|
|
\$this->lastPost = \$lastPost; |
627
|
|
|
return \$this; |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* For property "lastPost" |
632
|
|
|
* @return \AppBundle\Entity\Post |
633
|
|
|
*/ |
634
|
|
|
public function getLastPost() |
635
|
|
|
{ |
636
|
|
|
return \$this->lastPost; |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
EOT; |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* @var string |
645
|
|
|
*/ |
646
|
|
|
protected $userInterfaceExpected = <<<EOT |
647
|
|
|
<?php |
648
|
|
|
|
649
|
|
|
namespace AppBundle\Entity; |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Interface for entity : \AppBundle\Entity\User |
653
|
|
|
*/ |
654
|
|
|
interface UserInterface |
655
|
|
|
{ |
656
|
|
|
|
657
|
|
|
/** |
658
|
|
|
* For property "username" |
659
|
|
|
* @param string \$username |
660
|
|
|
* @return \$this |
661
|
|
|
*/ |
662
|
|
|
public function setUsername(\$username); |
663
|
|
|
|
664
|
|
|
/** |
665
|
|
|
* For property "username" |
666
|
|
|
* @return string |
667
|
|
|
*/ |
668
|
|
|
public function getUsername(); |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* For property "email" |
672
|
|
|
* @param string \$email |
673
|
|
|
* @return \$this |
674
|
|
|
*/ |
675
|
|
|
public function setEmail(\$email); |
676
|
|
|
|
677
|
|
|
/** |
678
|
|
|
* For property "email" |
679
|
|
|
* @return string |
680
|
|
|
*/ |
681
|
|
|
public function getEmail(); |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* For property "active" |
685
|
|
|
* @return boolean |
686
|
|
|
*/ |
687
|
|
|
public function isActive(); |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* For property "active" |
691
|
|
|
* @param boolean \$active |
692
|
|
|
* @return \$this |
693
|
|
|
*/ |
694
|
|
|
public function setActive(\$active); |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* For property "active" |
698
|
|
|
* @return boolean |
699
|
|
|
*/ |
700
|
|
|
public function getActive(); |
701
|
|
|
|
702
|
|
|
/** |
703
|
|
|
* For property "posts" |
704
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection \$posts |
705
|
|
|
* @return \$this |
706
|
|
|
*/ |
707
|
|
|
public function setPosts(\Doctrine\Common\Collections\ArrayCollection \$posts); |
708
|
|
|
|
709
|
|
|
/** |
710
|
|
|
* For property "posts" |
711
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
712
|
|
|
*/ |
713
|
|
|
public function getPosts(); |
714
|
|
|
|
715
|
|
|
/** |
716
|
|
|
* For property "createdAt" |
717
|
|
|
* @param \DateTime \$createdAt |
718
|
|
|
* @return \$this |
719
|
|
|
*/ |
720
|
|
|
public function setCreatedAt(\DateTime \$createdAt); |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* For property "createdAt" |
724
|
|
|
* @return \DateTime |
725
|
|
|
*/ |
726
|
|
|
public function getCreatedAt(); |
727
|
|
|
|
728
|
|
|
/** |
729
|
|
|
* For property "updatedAt" |
730
|
|
|
* @param \DateTime \$updatedAt |
731
|
|
|
* @return \$this |
732
|
|
|
*/ |
733
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt); |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* For property "updatedAt" |
737
|
|
|
* @return \DateTime |
738
|
|
|
*/ |
739
|
|
|
public function getUpdatedAt(); |
740
|
|
|
|
741
|
|
|
/** |
742
|
|
|
* For property "lastPost" |
743
|
|
|
* @param \AppBundle\Entity\Post \$lastPost |
744
|
|
|
* @return \$this |
745
|
|
|
*/ |
746
|
|
|
public function setLastPost(\AppBundle\Entity\Post \$lastPost = null); |
747
|
|
|
|
748
|
|
|
/** |
749
|
|
|
* For property "lastPost" |
750
|
|
|
* @return \AppBundle\Entity\Post |
751
|
|
|
*/ |
752
|
|
|
public function getLastPost(); |
753
|
|
|
|
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
EOT; |
757
|
|
|
|
758
|
|
|
/** |
759
|
|
|
* @var string |
760
|
|
|
*/ |
761
|
|
|
protected $postInterfaceExpected = <<<EOT |
762
|
|
|
<?php |
763
|
|
|
|
764
|
|
|
namespace AppBundle\Entity; |
765
|
|
|
|
766
|
|
|
/** |
767
|
|
|
* Interface for entity : \AppBundle\Entity\Post |
768
|
|
|
*/ |
769
|
|
|
interface PostInterface |
770
|
|
|
{ |
771
|
|
|
|
772
|
|
|
/** |
773
|
|
|
* For property "content" |
774
|
|
|
* @param string \$content |
775
|
|
|
* @return \$this |
776
|
|
|
*/ |
777
|
|
|
public function setContent(\$content); |
778
|
|
|
|
779
|
|
|
/** |
780
|
|
|
* For property "content" |
781
|
|
|
* @return string |
782
|
|
|
*/ |
783
|
|
|
public function getContent(); |
784
|
|
|
|
785
|
|
|
/** |
786
|
|
|
* For property "createdAt" |
787
|
|
|
* @param \DateTime \$createdAt |
788
|
|
|
* @return \$this |
789
|
|
|
*/ |
790
|
|
|
public function setCreatedAt(\DateTime \$createdAt); |
791
|
|
|
|
792
|
|
|
/** |
793
|
|
|
* For property "createdAt" |
794
|
|
|
* @return \DateTime |
795
|
|
|
*/ |
796
|
|
|
public function getCreatedAt(); |
797
|
|
|
|
798
|
|
|
/** |
799
|
|
|
* For property "updatedAt" |
800
|
|
|
* @param \DateTime \$updatedAt |
801
|
|
|
* @return \$this |
802
|
|
|
*/ |
803
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt); |
804
|
|
|
|
805
|
|
|
/** |
806
|
|
|
* For property "updatedAt" |
807
|
|
|
* @return \DateTime |
808
|
|
|
*/ |
809
|
|
|
public function getUpdatedAt(); |
810
|
|
|
|
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
EOT; |
814
|
|
|
|
815
|
|
|
/** |
816
|
|
|
* @var string |
817
|
|
|
*/ |
818
|
|
|
protected $userTestClassExpected = <<<EOT |
819
|
|
|
<?php |
820
|
|
|
|
821
|
|
|
namespace AppBundle\Tests\Entity; |
822
|
|
|
|
823
|
|
|
/** |
824
|
|
|
* Test for \AppBundle\Entity\User |
825
|
|
|
*/ |
826
|
|
|
class UserTest extends \PHPUnit_Framework_TestCase |
827
|
|
|
{ |
828
|
|
|
|
829
|
|
|
/** |
830
|
|
|
* Entity to test |
831
|
|
|
* @var \AppBundle\Entity\UserInterface |
832
|
|
|
*/ |
833
|
|
|
private \$object = null; |
834
|
|
|
|
835
|
|
|
public function setUp() |
836
|
|
|
{ |
837
|
|
|
\$this->object = new \AppBundle\Entity\User(); |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
public function testConstructor() |
841
|
|
|
{ |
842
|
|
|
\$this->assertNotNull(\$this->object); |
843
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\UserInterface', \$this->object); |
844
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\User', \$this->object); |
845
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\Base', \$this->object); |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
|
849
|
|
|
/** |
850
|
|
|
* @covers \AppBundle\Entity\User::setUsername |
851
|
|
|
*/ |
852
|
|
|
public function testSetUsername() |
853
|
|
|
{ |
854
|
|
|
\$this->markTestIncomplete( |
855
|
|
|
'This test has not been implemented yet.' |
856
|
|
|
); |
857
|
|
|
} |
858
|
|
|
|
859
|
|
|
/** |
860
|
|
|
* @covers \AppBundle\Entity\User::getUsername |
861
|
|
|
*/ |
862
|
|
|
public function testGetUsername() |
863
|
|
|
{ |
864
|
|
|
\$this->markTestIncomplete( |
865
|
|
|
'This test has not been implemented yet.' |
866
|
|
|
); |
867
|
|
|
} |
868
|
|
|
|
869
|
|
|
/** |
870
|
|
|
* @covers \AppBundle\Entity\User::setEmail |
871
|
|
|
*/ |
872
|
|
|
public function testSetEmail() |
873
|
|
|
{ |
874
|
|
|
\$this->markTestIncomplete( |
875
|
|
|
'This test has not been implemented yet.' |
876
|
|
|
); |
877
|
|
|
} |
878
|
|
|
|
879
|
|
|
/** |
880
|
|
|
* @covers \AppBundle\Entity\User::getEmail |
881
|
|
|
*/ |
882
|
|
|
public function testGetEmail() |
883
|
|
|
{ |
884
|
|
|
\$this->markTestIncomplete( |
885
|
|
|
'This test has not been implemented yet.' |
886
|
|
|
); |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
/** |
890
|
|
|
* @covers \AppBundle\Entity\User::isActive |
891
|
|
|
*/ |
892
|
|
|
public function testIsActive() |
893
|
|
|
{ |
894
|
|
|
\$this->markTestIncomplete( |
895
|
|
|
'This test has not been implemented yet.' |
896
|
|
|
); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
/** |
900
|
|
|
* @covers \AppBundle\Entity\User::setActive |
901
|
|
|
*/ |
902
|
|
|
public function testSetActive() |
903
|
|
|
{ |
904
|
|
|
\$this->markTestIncomplete( |
905
|
|
|
'This test has not been implemented yet.' |
906
|
|
|
); |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* @covers \AppBundle\Entity\User::getActive |
911
|
|
|
*/ |
912
|
|
|
public function testGetActive() |
913
|
|
|
{ |
914
|
|
|
\$this->markTestIncomplete( |
915
|
|
|
'This test has not been implemented yet.' |
916
|
|
|
); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* @covers \AppBundle\Entity\User::setPosts |
921
|
|
|
*/ |
922
|
|
|
public function testSetPosts() |
923
|
|
|
{ |
924
|
|
|
\$this->markTestIncomplete( |
925
|
|
|
'This test has not been implemented yet.' |
926
|
|
|
); |
927
|
|
|
} |
928
|
|
|
|
929
|
|
|
/** |
930
|
|
|
* @covers \AppBundle\Entity\User::getPosts |
931
|
|
|
*/ |
932
|
|
|
public function testGetPosts() |
933
|
|
|
{ |
934
|
|
|
\$this->markTestIncomplete( |
935
|
|
|
'This test has not been implemented yet.' |
936
|
|
|
); |
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
/** |
940
|
|
|
* @covers \AppBundle\Entity\User::setCreatedAt |
941
|
|
|
*/ |
942
|
|
|
public function testSetCreatedAt() |
943
|
|
|
{ |
944
|
|
|
\$this->markTestIncomplete( |
945
|
|
|
'This test has not been implemented yet.' |
946
|
|
|
); |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
/** |
950
|
|
|
* @covers \AppBundle\Entity\User::getCreatedAt |
951
|
|
|
*/ |
952
|
|
|
public function testGetCreatedAt() |
953
|
|
|
{ |
954
|
|
|
\$this->markTestIncomplete( |
955
|
|
|
'This test has not been implemented yet.' |
956
|
|
|
); |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
/** |
960
|
|
|
* @covers \AppBundle\Entity\User::setUpdatedAt |
961
|
|
|
*/ |
962
|
|
|
public function testSetUpdatedAt() |
963
|
|
|
{ |
964
|
|
|
\$this->markTestIncomplete( |
965
|
|
|
'This test has not been implemented yet.' |
966
|
|
|
); |
967
|
|
|
} |
968
|
|
|
|
969
|
|
|
/** |
970
|
|
|
* @covers \AppBundle\Entity\User::getUpdatedAt |
971
|
|
|
*/ |
972
|
|
|
public function testGetUpdatedAt() |
973
|
|
|
{ |
974
|
|
|
\$this->markTestIncomplete( |
975
|
|
|
'This test has not been implemented yet.' |
976
|
|
|
); |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
/** |
980
|
|
|
* @covers \AppBundle\Entity\User::setLastPost |
981
|
|
|
*/ |
982
|
|
|
public function testSetLastPost() |
983
|
|
|
{ |
984
|
|
|
\$this->markTestIncomplete( |
985
|
|
|
'This test has not been implemented yet.' |
986
|
|
|
); |
987
|
|
|
} |
988
|
|
|
|
989
|
|
|
/** |
990
|
|
|
* @covers \AppBundle\Entity\User::getLastPost |
991
|
|
|
*/ |
992
|
|
|
public function testGetLastPost() |
993
|
|
|
{ |
994
|
|
|
\$this->markTestIncomplete( |
995
|
|
|
'This test has not been implemented yet.' |
996
|
|
|
); |
997
|
|
|
} |
998
|
|
|
|
999
|
|
|
} |
1000
|
|
|
|
1001
|
|
|
EOT; |
1002
|
|
|
|
1003
|
|
|
/** |
1004
|
|
|
* @var string |
1005
|
|
|
*/ |
1006
|
|
|
protected $postTestClassExpected = <<<EOT |
1007
|
|
|
<?php |
1008
|
|
|
|
1009
|
|
|
namespace AppBundle\Tests\Entity; |
1010
|
|
|
|
1011
|
|
|
/** |
1012
|
|
|
* Test for \AppBundle\Entity\Post |
1013
|
|
|
*/ |
1014
|
|
|
class PostTest extends \PHPUnit_Framework_TestCase |
1015
|
|
|
{ |
1016
|
|
|
|
1017
|
|
|
/** |
1018
|
|
|
* Entity to test |
1019
|
|
|
* @var \AppBundle\Entity\PostInterface |
1020
|
|
|
*/ |
1021
|
|
|
private \$object = null; |
1022
|
|
|
|
1023
|
|
|
public function setUp() |
1024
|
|
|
{ |
1025
|
|
|
\$this->object = new \AppBundle\Entity\Post(); |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
public function testConstructor() |
1029
|
|
|
{ |
1030
|
|
|
\$this->assertNotNull(\$this->object); |
1031
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\PostInterface', \$this->object); |
1032
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\Post', \$this->object); |
1033
|
|
|
} |
1034
|
|
|
|
1035
|
|
|
|
1036
|
|
|
/** |
1037
|
|
|
* @covers \AppBundle\Entity\Post::setContent |
1038
|
|
|
*/ |
1039
|
|
|
public function testSetContent() |
1040
|
|
|
{ |
1041
|
|
|
\$this->markTestIncomplete( |
1042
|
|
|
'This test has not been implemented yet.' |
1043
|
|
|
); |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
/** |
1047
|
|
|
* @covers \AppBundle\Entity\Post::getContent |
1048
|
|
|
*/ |
1049
|
|
|
public function testGetContent() |
1050
|
|
|
{ |
1051
|
|
|
\$this->markTestIncomplete( |
1052
|
|
|
'This test has not been implemented yet.' |
1053
|
|
|
); |
1054
|
|
|
} |
1055
|
|
|
|
1056
|
|
|
/** |
1057
|
|
|
* @covers \AppBundle\Entity\Post::setCreatedAt |
1058
|
|
|
*/ |
1059
|
|
|
public function testSetCreatedAt() |
1060
|
|
|
{ |
1061
|
|
|
\$this->markTestIncomplete( |
1062
|
|
|
'This test has not been implemented yet.' |
1063
|
|
|
); |
1064
|
|
|
} |
1065
|
|
|
|
1066
|
|
|
/** |
1067
|
|
|
* @covers \AppBundle\Entity\Post::getCreatedAt |
1068
|
|
|
*/ |
1069
|
|
|
public function testGetCreatedAt() |
1070
|
|
|
{ |
1071
|
|
|
\$this->markTestIncomplete( |
1072
|
|
|
'This test has not been implemented yet.' |
1073
|
|
|
); |
1074
|
|
|
} |
1075
|
|
|
|
1076
|
|
|
/** |
1077
|
|
|
* @covers \AppBundle\Entity\Post::setUpdatedAt |
1078
|
|
|
*/ |
1079
|
|
|
public function testSetUpdatedAt() |
1080
|
|
|
{ |
1081
|
|
|
\$this->markTestIncomplete( |
1082
|
|
|
'This test has not been implemented yet.' |
1083
|
|
|
); |
1084
|
|
|
} |
1085
|
|
|
|
1086
|
|
|
/** |
1087
|
|
|
* @covers \AppBundle\Entity\Post::getUpdatedAt |
1088
|
|
|
*/ |
1089
|
|
|
public function testGetUpdatedAt() |
1090
|
|
|
{ |
1091
|
|
|
\$this->markTestIncomplete( |
1092
|
|
|
'This test has not been implemented yet.' |
1093
|
|
|
); |
1094
|
|
|
} |
1095
|
|
|
|
1096
|
|
|
} |
1097
|
|
|
|
1098
|
|
|
EOT; |
1099
|
|
|
protected $postClassWithoutInterface = <<<EOT |
1100
|
|
|
<?php |
1101
|
|
|
|
1102
|
|
|
namespace AppBundle\Entity; |
1103
|
|
|
|
1104
|
|
|
/** |
1105
|
|
|
* |
1106
|
|
|
* |
1107
|
|
|
*/ |
1108
|
|
|
class Post |
1109
|
|
|
{ |
1110
|
|
|
|
1111
|
|
|
/** |
1112
|
|
|
* Post content |
1113
|
|
|
* |
1114
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank() |
1115
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
1116
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("content") |
1117
|
|
|
* @var string |
1118
|
|
|
*/ |
1119
|
|
|
private \$content; |
1120
|
|
|
|
1121
|
|
|
/** |
1122
|
|
|
* 'created_at' property |
1123
|
|
|
* |
1124
|
|
|
* |
1125
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
1126
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("created_at") |
1127
|
|
|
* @var \DateTime |
1128
|
|
|
*/ |
1129
|
|
|
private \$createdAt; |
1130
|
|
|
|
1131
|
|
|
/** |
1132
|
|
|
* 'updated_at' property |
1133
|
|
|
* |
1134
|
|
|
* |
1135
|
|
|
* @\JMS\Serializer\Annotation\Type("DateTime") |
1136
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("updated_at") |
1137
|
|
|
* @var \DateTime |
1138
|
|
|
*/ |
1139
|
|
|
private \$updatedAt; |
1140
|
|
|
|
1141
|
|
|
|
1142
|
|
|
/** |
1143
|
|
|
* Constructor. |
1144
|
|
|
*/ |
1145
|
|
|
public function __construct() |
1146
|
|
|
{ |
1147
|
|
|
|
1148
|
|
|
} |
1149
|
|
|
|
1150
|
|
|
|
1151
|
|
|
/** |
1152
|
|
|
* For property "content" |
1153
|
|
|
* @param string \$content |
1154
|
|
|
* @return \$this |
1155
|
|
|
*/ |
1156
|
|
|
public function setContent(\$content) |
1157
|
|
|
{ |
1158
|
|
|
\$this->content = \$content; |
1159
|
|
|
return \$this; |
1160
|
|
|
} |
1161
|
|
|
|
1162
|
|
|
/** |
1163
|
|
|
* For property "content" |
1164
|
|
|
* @return string |
1165
|
|
|
*/ |
1166
|
|
|
public function getContent() |
1167
|
|
|
{ |
1168
|
|
|
return \$this->content; |
1169
|
|
|
} |
1170
|
|
|
|
1171
|
|
|
/** |
1172
|
|
|
* For property "createdAt" |
1173
|
|
|
* @param \DateTime \$createdAt |
1174
|
|
|
* @return \$this |
1175
|
|
|
*/ |
1176
|
|
|
public function setCreatedAt(\DateTime \$createdAt) |
1177
|
|
|
{ |
1178
|
|
|
\$this->createdAt = \$createdAt; |
1179
|
|
|
return \$this; |
1180
|
|
|
} |
1181
|
|
|
|
1182
|
|
|
/** |
1183
|
|
|
* For property "createdAt" |
1184
|
|
|
* @return \DateTime |
1185
|
|
|
*/ |
1186
|
|
|
public function getCreatedAt() |
1187
|
|
|
{ |
1188
|
|
|
return \$this->createdAt; |
1189
|
|
|
} |
1190
|
|
|
|
1191
|
|
|
/** |
1192
|
|
|
* For property "updatedAt" |
1193
|
|
|
* @param \DateTime \$updatedAt |
1194
|
|
|
* @return \$this |
1195
|
|
|
*/ |
1196
|
|
|
public function setUpdatedAt(\DateTime \$updatedAt) |
1197
|
|
|
{ |
1198
|
|
|
\$this->updatedAt = \$updatedAt; |
1199
|
|
|
return \$this; |
1200
|
|
|
} |
1201
|
|
|
|
1202
|
|
|
/** |
1203
|
|
|
* For property "updatedAt" |
1204
|
|
|
* @return \DateTime |
1205
|
|
|
*/ |
1206
|
|
|
public function getUpdatedAt() |
1207
|
|
|
{ |
1208
|
|
|
return \$this->updatedAt; |
1209
|
|
|
} |
1210
|
|
|
|
1211
|
|
|
} |
1212
|
|
|
|
1213
|
|
|
EOT; |
1214
|
|
|
|
1215
|
|
|
/** |
1216
|
|
|
* @var string |
1217
|
|
|
*/ |
1218
|
|
|
protected $postTestClassWithoutInterface = <<<EOT |
1219
|
|
|
<?php |
1220
|
|
|
|
1221
|
|
|
namespace AppBundle\Tests\Entity; |
1222
|
|
|
|
1223
|
|
|
/** |
1224
|
|
|
* Test for \AppBundle\Entity\Post |
1225
|
|
|
*/ |
1226
|
|
|
class PostTest extends \PHPUnit_Framework_TestCase |
1227
|
|
|
{ |
1228
|
|
|
|
1229
|
|
|
/** |
1230
|
|
|
* Entity to test |
1231
|
|
|
* @var \AppBundle\Entity\Post |
1232
|
|
|
*/ |
1233
|
|
|
private \$object = null; |
1234
|
|
|
|
1235
|
|
|
public function setUp() |
1236
|
|
|
{ |
1237
|
|
|
\$this->object = new \AppBundle\Entity\Post(); |
1238
|
|
|
} |
1239
|
|
|
|
1240
|
|
|
public function testConstructor() |
1241
|
|
|
{ |
1242
|
|
|
\$this->assertNotNull(\$this->object); |
1243
|
|
|
\$this->assertInstanceof('\AppBundle\Entity\Post', \$this->object); |
1244
|
|
|
} |
1245
|
|
|
|
1246
|
|
|
|
1247
|
|
|
/** |
1248
|
|
|
* @covers \AppBundle\Entity\Post::setContent |
1249
|
|
|
*/ |
1250
|
|
|
public function testSetContent() |
1251
|
|
|
{ |
1252
|
|
|
\$this->markTestIncomplete( |
1253
|
|
|
'This test has not been implemented yet.' |
1254
|
|
|
); |
1255
|
|
|
} |
1256
|
|
|
|
1257
|
|
|
/** |
1258
|
|
|
* @covers \AppBundle\Entity\Post::getContent |
1259
|
|
|
*/ |
1260
|
|
|
public function testGetContent() |
1261
|
|
|
{ |
1262
|
|
|
\$this->markTestIncomplete( |
1263
|
|
|
'This test has not been implemented yet.' |
1264
|
|
|
); |
1265
|
|
|
} |
1266
|
|
|
|
1267
|
|
|
/** |
1268
|
|
|
* @covers \AppBundle\Entity\Post::setCreatedAt |
1269
|
|
|
*/ |
1270
|
|
|
public function testSetCreatedAt() |
1271
|
|
|
{ |
1272
|
|
|
\$this->markTestIncomplete( |
1273
|
|
|
'This test has not been implemented yet.' |
1274
|
|
|
); |
1275
|
|
|
} |
1276
|
|
|
|
1277
|
|
|
/** |
1278
|
|
|
* @covers \AppBundle\Entity\Post::getCreatedAt |
1279
|
|
|
*/ |
1280
|
|
|
public function testGetCreatedAt() |
1281
|
|
|
{ |
1282
|
|
|
\$this->markTestIncomplete( |
1283
|
|
|
'This test has not been implemented yet.' |
1284
|
|
|
); |
1285
|
|
|
} |
1286
|
|
|
|
1287
|
|
|
/** |
1288
|
|
|
* @covers \AppBundle\Entity\Post::setUpdatedAt |
1289
|
|
|
*/ |
1290
|
|
|
public function testSetUpdatedAt() |
1291
|
|
|
{ |
1292
|
|
|
\$this->markTestIncomplete( |
1293
|
|
|
'This test has not been implemented yet.' |
1294
|
|
|
); |
1295
|
|
|
} |
1296
|
|
|
|
1297
|
|
|
/** |
1298
|
|
|
* @covers \AppBundle\Entity\Post::getUpdatedAt |
1299
|
|
|
*/ |
1300
|
|
|
public function testGetUpdatedAt() |
1301
|
|
|
{ |
1302
|
|
|
\$this->markTestIncomplete( |
1303
|
|
|
'This test has not been implemented yet.' |
1304
|
|
|
); |
1305
|
|
|
} |
1306
|
|
|
|
1307
|
|
|
} |
1308
|
|
|
|
1309
|
|
|
EOT; |
1310
|
|
|
|
1311
|
|
|
/** |
1312
|
|
|
* @var string |
1313
|
|
|
*/ |
1314
|
|
|
protected $userClassWithTemplatesSetExpected = <<<EOT |
1315
|
|
|
<?php |
1316
|
|
|
|
1317
|
|
|
namespace AppBundle\Entity; |
1318
|
|
|
|
1319
|
|
|
/** |
1320
|
|
|
* My own class template |
1321
|
|
|
* New User entity |
1322
|
|
|
* lorem ipsum |
1323
|
|
|
* second row |
1324
|
|
|
* @\Doctrine\Common\Annotations\Entity() |
1325
|
|
|
*/ |
1326
|
|
|
class User extends \AppBundle\Entity\Base implements \AppBundle\Entity\UserInterface |
1327
|
|
|
{ |
1328
|
|
|
|
1329
|
|
|
/** |
1330
|
|
|
* My own protected property |
1331
|
|
|
* 'id' property |
1332
|
|
|
* |
1333
|
|
|
* |
1334
|
|
|
* @\JMS\Serializer\Annotation\Type("integer") |
1335
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("id") |
1336
|
|
|
* @var integer |
1337
|
|
|
*/ |
1338
|
|
|
protected \$id; |
1339
|
|
|
|
1340
|
|
|
/** |
1341
|
|
|
* Username for login |
1342
|
|
|
* |
1343
|
|
|
* @\Symfony\Component\Validator\Constraints\NotBlank(message = "Login can not be empty") |
1344
|
|
|
* @\Symfony\Component\Validator\Constraints\NotNull(message = "Login can not be null") |
1345
|
|
|
* @\JMS\Serializer\Annotation\Type("string") |
1346
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("username") |
1347
|
|
|
* @var string |
1348
|
|
|
*/ |
1349
|
|
|
private \$username; |
1350
|
|
|
|
1351
|
|
|
/** |
1352
|
|
|
* User posts |
1353
|
|
|
* |
1354
|
|
|
* |
1355
|
|
|
* @\JMS\Serializer\Annotation\Type("Doctrine\Common\Collections\ArrayCollection<AppBundle\Entity\Post>") |
1356
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("posts") |
1357
|
|
|
* @var \Doctrine\Common\Collections\ArrayCollection |
1358
|
|
|
*/ |
1359
|
|
|
private \$posts; |
1360
|
|
|
|
1361
|
|
|
/** |
1362
|
|
|
* Wether user is active or not |
1363
|
|
|
* |
1364
|
|
|
* @\Symfony\Component\Validator\Constraints\IsTrue() |
1365
|
|
|
* @\JMS\Serializer\Annotation\Type("boolean") |
1366
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("active") |
1367
|
|
|
* @var boolean |
1368
|
|
|
*/ |
1369
|
|
|
private \$active; |
1370
|
|
|
|
1371
|
|
|
|
1372
|
|
|
/** |
1373
|
|
|
* Constructor. |
1374
|
|
|
* My own CONSTRUCT with parameter |
1375
|
|
|
*/ |
1376
|
|
|
public function __construct(\$zm) |
1377
|
|
|
{ |
1378
|
|
|
\$zm1 = \$zm; |
1379
|
|
|
\$this->posts = new \Doctrine\Common\Collections\ArrayCollection(); |
1380
|
|
|
} |
1381
|
|
|
|
1382
|
|
|
|
1383
|
|
|
/** |
1384
|
|
|
* For property "id" |
1385
|
|
|
* @param integer \$id |
1386
|
|
|
* @return \$this |
1387
|
|
|
*/ |
1388
|
|
|
final public function setId(\$id) |
1389
|
|
|
{ |
1390
|
|
|
// this is final setter |
1391
|
|
|
\$this->id = \$id; |
1392
|
|
|
return \$this; |
1393
|
|
|
} |
1394
|
|
|
|
1395
|
|
|
/** |
1396
|
|
|
* For property "id" |
1397
|
|
|
* My own getter template, I can do everything |
1398
|
|
|
* @return integer |
1399
|
|
|
*/ |
1400
|
|
|
public function getId(\$defaultValue = "default") |
1401
|
|
|
{ |
1402
|
|
|
if (empty(\$this->id)) { |
1403
|
|
|
return \$defaultValue; |
1404
|
|
|
} |
1405
|
|
|
|
1406
|
|
|
return \$this->id; |
1407
|
|
|
} |
1408
|
|
|
|
1409
|
|
|
/** |
1410
|
|
|
* For property "username" |
1411
|
|
|
* @param string \$username |
1412
|
|
|
* @return \$this |
1413
|
|
|
*/ |
1414
|
|
|
public function setUsername(\$username) |
1415
|
|
|
{ |
1416
|
|
|
\$this->username = \$username; |
1417
|
|
|
return \$this; |
1418
|
|
|
} |
1419
|
|
|
|
1420
|
|
|
/** |
1421
|
|
|
* For property "username" |
1422
|
|
|
* @return string |
1423
|
|
|
*/ |
1424
|
|
|
public function getUsername() |
1425
|
|
|
{ |
1426
|
|
|
return \$this->username; |
1427
|
|
|
} |
1428
|
|
|
|
1429
|
|
|
/** |
1430
|
|
|
* For property "posts" |
1431
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection \$posts |
1432
|
|
|
* @return \$this |
1433
|
|
|
*/ |
1434
|
|
|
public function setPosts(\Doctrine\Common\Collections\ArrayCollection \$posts) |
1435
|
|
|
{ |
1436
|
|
|
\$this->posts = \$posts; |
1437
|
|
|
return \$this; |
1438
|
|
|
} |
1439
|
|
|
|
1440
|
|
|
/** |
1441
|
|
|
* For property "posts" |
1442
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
1443
|
|
|
*/ |
1444
|
|
|
public function getPosts() |
1445
|
|
|
{ |
1446
|
|
|
return \$this->posts; |
1447
|
|
|
} |
1448
|
|
|
|
1449
|
|
|
/** |
1450
|
|
|
* For property "active" My own getter boolean template |
1451
|
|
|
* @return boolean |
1452
|
|
|
*/ |
1453
|
|
|
public function isActive() |
1454
|
|
|
{ |
1455
|
|
|
return (bool) \$this->active; |
1456
|
|
|
} |
1457
|
|
|
|
1458
|
|
|
/** |
1459
|
|
|
* For property "active" |
1460
|
|
|
* @param boolean \$active |
1461
|
|
|
* @return \$this |
1462
|
|
|
*/ |
1463
|
|
|
public function setActive(\$active) |
1464
|
|
|
{ |
1465
|
|
|
\$this->active = \$active; |
1466
|
|
|
return \$this; |
1467
|
|
|
} |
1468
|
|
|
|
1469
|
|
|
|
1470
|
|
|
|
1471
|
|
|
|
1472
|
|
|
/** |
1473
|
|
|
* nothing to do |
1474
|
|
|
*/ |
1475
|
|
|
public function __toString() |
1476
|
|
|
{ |
1477
|
|
|
return sprintf("class: %s", __CLASS__); |
1478
|
|
|
} |
1479
|
|
|
} |
1480
|
|
|
|
1481
|
|
|
EOT; |
1482
|
|
|
|
1483
|
|
|
/** |
1484
|
|
|
* @var string |
1485
|
|
|
*/ |
1486
|
|
|
protected $userInterfaceWithTemplatesSetExpected = <<<EOT |
1487
|
|
|
<?php |
1488
|
|
|
|
1489
|
|
|
namespace AppBundle\Entity; |
1490
|
|
|
|
1491
|
|
|
/** |
1492
|
|
|
* My own interface template |
1493
|
|
|
* Interface for entity : \AppBundle\Entity\User |
1494
|
|
|
*/ |
1495
|
|
|
interface UserInterface |
1496
|
|
|
{ |
1497
|
|
|
|
1498
|
|
|
/** |
1499
|
|
|
* For property "id" |
1500
|
|
|
* @param integer \$id |
1501
|
|
|
* @return \$this |
1502
|
|
|
* My own setter interface, I do not want type hinting and optional part! |
1503
|
|
|
*/ |
1504
|
|
|
public function setId(\$id); |
1505
|
|
|
|
1506
|
|
|
/** |
1507
|
|
|
* For property "id" My own protected getter interface template |
1508
|
|
|
* @return integer |
1509
|
|
|
*/ |
1510
|
|
|
protected function getId(); |
1511
|
|
|
|
1512
|
|
|
/** |
1513
|
|
|
* For property "username" |
1514
|
|
|
* @param string \$username |
1515
|
|
|
* @return \$this |
1516
|
|
|
*/ |
1517
|
|
|
public function setUsername(\$username); |
1518
|
|
|
|
1519
|
|
|
/** |
1520
|
|
|
* For property "username" |
1521
|
|
|
* @return string |
1522
|
|
|
*/ |
1523
|
|
|
public function getUsername(); |
1524
|
|
|
|
1525
|
|
|
/** |
1526
|
|
|
* For property "posts" |
1527
|
|
|
* @param \Doctrine\Common\Collections\ArrayCollection \$posts |
1528
|
|
|
* @return \$this |
1529
|
|
|
*/ |
1530
|
|
|
public function setPosts(\Doctrine\Common\Collections\ArrayCollection \$posts); |
1531
|
|
|
|
1532
|
|
|
/** |
1533
|
|
|
* For property "posts" |
1534
|
|
|
* @return \Doctrine\Common\Collections\ArrayCollection |
1535
|
|
|
*/ |
1536
|
|
|
public function getPosts(); |
1537
|
|
|
|
1538
|
|
|
/** |
1539
|
|
|
* For property "active" |
1540
|
|
|
* @return boolean |
1541
|
|
|
*/ |
1542
|
|
|
public function isActiveMyOwn(); |
1543
|
|
|
|
1544
|
|
|
/** |
1545
|
|
|
* For property "active" |
1546
|
|
|
* @param boolean \$active |
1547
|
|
|
* @return \$this |
1548
|
|
|
*/ |
1549
|
|
|
public function setActive(\$active); |
1550
|
|
|
|
1551
|
|
|
/** |
1552
|
|
|
* For property "active" |
1553
|
|
|
* @return boolean |
1554
|
|
|
*/ |
1555
|
|
|
public function getActive(); |
1556
|
|
|
|
1557
|
|
|
} |
1558
|
|
|
|
1559
|
|
|
EOT; |
1560
|
|
|
|
1561
|
|
|
/** |
1562
|
|
|
* @var string |
1563
|
|
|
*/ |
1564
|
|
|
protected $userTestClassWithTemplatesSetExpected = <<<EOT |
1565
|
|
|
<?php |
1566
|
|
|
|
1567
|
|
|
namespace AppBundle\Tests\Entity; |
1568
|
|
|
|
1569
|
|
|
/** |
1570
|
|
|
* I do not want to init object! |
1571
|
|
|
*/ |
1572
|
|
|
class UserTest extends \PHPUnit_Framework_TestCase |
1573
|
|
|
{ |
1574
|
|
|
|
1575
|
|
|
/** |
1576
|
|
|
* @covers \AppBundle\Entity\User::setId |
1577
|
|
|
*/ |
1578
|
|
|
public function testSetId() |
1579
|
|
|
{ |
1580
|
|
|
\$this->markTestIncomplete( |
1581
|
|
|
'This test has not been implemented yet. Some.' |
1582
|
|
|
); |
1583
|
|
|
// My own test method!! |
1584
|
|
|
} |
1585
|
|
|
|
1586
|
|
|
/** |
1587
|
|
|
* @covers \AppBundle\Entity\User::getId |
1588
|
|
|
*/ |
1589
|
|
|
public function testGetId() |
1590
|
|
|
{ |
1591
|
|
|
\$this->markTestIncomplete( |
1592
|
|
|
'This test has not been implemented yet. Some.' |
1593
|
|
|
); |
1594
|
|
|
// My own test method!! |
1595
|
|
|
} |
1596
|
|
|
|
1597
|
|
|
/** |
1598
|
|
|
* @covers \AppBundle\Entity\User::setUsername |
1599
|
|
|
*/ |
1600
|
|
|
public function testSetUsername() |
1601
|
|
|
{ |
1602
|
|
|
\$this->markTestIncomplete( |
1603
|
|
|
'This test has not been implemented yet.' |
1604
|
|
|
); |
1605
|
|
|
} |
1606
|
|
|
|
1607
|
|
|
/** |
1608
|
|
|
* @covers \AppBundle\Entity\User::getUsername |
1609
|
|
|
*/ |
1610
|
|
|
public function testGetUsername() |
1611
|
|
|
{ |
1612
|
|
|
\$this->markTestIncomplete( |
1613
|
|
|
'This test has not been implemented yet.' |
1614
|
|
|
); |
1615
|
|
|
} |
1616
|
|
|
|
1617
|
|
|
/** |
1618
|
|
|
* @covers \AppBundle\Entity\User::setPosts |
1619
|
|
|
*/ |
1620
|
|
|
public function testSetPosts() |
1621
|
|
|
{ |
1622
|
|
|
\$this->markTestIncomplete( |
1623
|
|
|
'This test has not been implemented yet.' |
1624
|
|
|
); |
1625
|
|
|
} |
1626
|
|
|
|
1627
|
|
|
/** |
1628
|
|
|
* @covers \AppBundle\Entity\User::getPosts |
1629
|
|
|
*/ |
1630
|
|
|
public function testGetPosts() |
1631
|
|
|
{ |
1632
|
|
|
\$this->markTestIncomplete( |
1633
|
|
|
'This test has not been implemented yet.' |
1634
|
|
|
); |
1635
|
|
|
} |
1636
|
|
|
|
1637
|
|
|
/** |
1638
|
|
|
* @covers \AppBundle\Entity\User::isActive |
1639
|
|
|
*/ |
1640
|
|
|
public function testIsActive() |
1641
|
|
|
{ |
1642
|
|
|
\$this->markTestIncomplete( |
1643
|
|
|
'This test has not been implemented yet.' |
1644
|
|
|
); |
1645
|
|
|
} |
1646
|
|
|
|
1647
|
|
|
/** |
1648
|
|
|
* @covers \AppBundle\Entity\User::setActive |
1649
|
|
|
*/ |
1650
|
|
|
public function testSetActive() |
1651
|
|
|
{ |
1652
|
|
|
\$this->markTestIncomplete( |
1653
|
|
|
'This test has not been implemented yet.' |
1654
|
|
|
); |
1655
|
|
|
} |
1656
|
|
|
|
1657
|
|
|
/** |
1658
|
|
|
* @covers \AppBundle\Entity\User::getActive |
1659
|
|
|
*/ |
1660
|
|
|
public function testGetActive() |
1661
|
|
|
{ |
1662
|
|
|
\$this->markTestIncomplete( |
1663
|
|
|
'This test has not been implemented yet.' |
1664
|
|
|
); |
1665
|
|
|
} |
1666
|
|
|
|
1667
|
|
|
} |
1668
|
|
|
|
1669
|
|
|
EOT; |
1670
|
|
|
|
1671
|
|
|
/** |
1672
|
|
|
* @var string |
1673
|
|
|
*/ |
1674
|
|
|
protected $postClassWithoutInterfaceExpected = <<<EOT |
1675
|
|
|
<?php |
1676
|
|
|
|
1677
|
|
|
namespace AppBundle\Entity; |
1678
|
|
|
|
1679
|
|
|
/** |
1680
|
|
|
* |
1681
|
|
|
* |
1682
|
|
|
*/ |
1683
|
|
|
class Post |
1684
|
|
|
{ |
1685
|
|
|
|
1686
|
|
|
/** |
1687
|
|
|
* 'id' property |
1688
|
|
|
* |
1689
|
|
|
* |
1690
|
|
|
* @\JMS\Serializer\Annotation\Type("integer") |
1691
|
|
|
* @\JMS\Serializer\Annotation\SerializedName("id") |
1692
|
|
|
* @var integer |
1693
|
|
|
*/ |
1694
|
|
|
private \$id; |
1695
|
|
|
|
1696
|
|
|
|
1697
|
|
|
/** |
1698
|
|
|
* Constructor. |
1699
|
|
|
*/ |
1700
|
|
|
public function __construct() |
1701
|
|
|
{ |
1702
|
|
|
|
1703
|
|
|
} |
1704
|
|
|
|
1705
|
|
|
|
1706
|
|
|
/** |
1707
|
|
|
* For property "id" |
1708
|
|
|
* @param integer \$id |
1709
|
|
|
* @return \$this |
1710
|
|
|
*/ |
1711
|
|
|
public function setId(\$id) |
1712
|
|
|
{ |
1713
|
|
|
\$this->id = \$id; |
1714
|
|
|
return \$this; |
1715
|
|
|
} |
1716
|
|
|
|
1717
|
|
|
/** |
1718
|
|
|
* For property "id" |
1719
|
|
|
* @return integer |
1720
|
|
|
*/ |
1721
|
|
|
public function getId() |
1722
|
|
|
{ |
1723
|
|
|
return \$this->id; |
1724
|
|
|
} |
1725
|
|
|
|
1726
|
|
|
} |
1727
|
|
|
|
1728
|
|
|
EOT; |
1729
|
|
|
|
1730
|
|
|
/** |
1731
|
|
|
* @dataProvider dataForTestRender |
1732
|
|
|
*/ |
1733
|
|
|
public function testRender($item, $expectedOutput) |
1734
|
|
|
{ |
1735
|
|
|
$result = $this->getRenderer()->render($item); |
1736
|
|
|
$this->assertEquals($expectedOutput, $result); |
1737
|
|
|
} |
1738
|
|
|
|
1739
|
|
|
public function dataForTestRender() |
1740
|
|
|
{ |
1741
|
|
|
$classManagers = $this->generateDataFromYamlHelper(); |
1742
|
|
|
$anotherClassManagers = $this->generateClassManagersFromYaml(Helper::getStructureYamlForTemplateChangeTest()); |
1743
|
|
|
$classManagersWithInlineConfiguration = $this->generateClassManagersFromYaml(Helper::getStructureYamlForTestInlineClassConfuration()); |
1744
|
|
|
|
1745
|
|
|
return [ |
1746
|
|
|
[$classManagers[0], $this->userClassExpected], |
1747
|
|
|
[$classManagers[1], $this->postClassExpected], |
1748
|
|
|
[$classManagers[0]->getInterface(), $this->userInterfaceExpected], |
1749
|
|
|
[$classManagers[1]->getInterface(), $this->postInterfaceExpected], |
1750
|
|
|
[$classManagers[0]->getTestClass(), $this->userTestClassExpected], |
1751
|
|
|
[$classManagers[1]->getTestClass(), $this->postTestClassExpected], |
1752
|
|
|
[$anotherClassManagers[0], $this->userClassWithTemplatesSetExpected], |
1753
|
|
|
[$anotherClassManagers[0]->getInterface(), $this->userInterfaceWithTemplatesSetExpected], |
1754
|
|
|
[$anotherClassManagers[0]->getTestClass(), $this->userTestClassWithTemplatesSetExpected], |
1755
|
|
|
[$classManagersWithInlineConfiguration[0], $this->postClassWithoutInterfaceExpected], |
1756
|
|
|
]; |
1757
|
|
|
} |
1758
|
|
|
|
1759
|
|
|
/** |
1760
|
|
|
* @dataProvider dataForTestRenderAndPutItemsToContent |
1761
|
|
|
*/ |
1762
|
|
|
public function testRenderAndPutItemsToContent($postClassExpected, $postClassWithNewPropertyExpected, $newItemPositionOffset) |
1763
|
|
|
{ |
1764
|
|
|
$itemsToRender = new ArrayCollection(); |
1765
|
|
|
$itemsToRender->add(Helper::prepareProperty("active", "boolean", "is post active", ["IsTrue()"])); |
1766
|
|
|
$result = $this->getRenderer()->renderAndPutItemsToContent($postClassExpected, $itemsToRender, $newItemPositionOffset); |
1767
|
|
|
$this->assertEquals($postClassWithNewPropertyExpected, $result); |
1768
|
|
|
} |
1769
|
|
|
|
1770
|
|
|
/** |
1771
|
|
|
* @dataProvider dataForTestRenderAndPutConstructorBodyToContent |
1772
|
|
|
*/ |
1773
|
|
|
public function testRenderAndPutConstructorBodyToContent($postClassExpected, $postClassWithUpdatedConstructor, $newItemPositionOffset) |
1774
|
|
|
{ |
1775
|
|
|
$constructorManager = new ClassConstructorManager(new ClassManager()); |
1776
|
|
|
$initProperties = new ArrayCollection(); |
1777
|
|
|
$initProperty = new InitPropertyManager(); |
1778
|
|
|
$initProperty->setProperty(Helper::prepareProperty("collection", "Doctrine\Common\Collections\ArrayCollection", "items collection", ["Valid(message = \"Collection has to be valid!\")"])); |
1779
|
|
|
$initProperty2 = new InitPropertyManager(); |
1780
|
|
|
$initProperty2->setProperty(Helper::prepareProperty("collection2", "Doctrine\Common\Collections\ArrayCollection", "items collection 2", ["Valid(message = \"Collection has to be valid!\")"])); |
1781
|
|
|
$initProperties->add($initProperty2); |
1782
|
|
|
$initProperties->add($initProperty); |
1783
|
|
|
$constructorManager->setInitProperties($initProperties); |
1784
|
|
|
$result = $this->getRenderer()->renderAndPutConstructorBodyToContent($postClassExpected, $constructorManager, $newItemPositionOffset); |
1785
|
|
|
$this->assertEquals($postClassWithUpdatedConstructor, $result); |
1786
|
|
|
} |
1787
|
|
|
|
1788
|
|
|
public function testRenderClassWithoutInterface() |
1789
|
|
|
{ |
1790
|
|
|
$class = $this->initDataFromYamlAndGetSecondClassWithoutInterface(); |
1791
|
|
|
$result = $this->getRenderer()->render($class); |
1792
|
|
|
$this->assertEquals($this->postClassWithoutInterface, $result); |
1793
|
|
|
} |
1794
|
|
|
|
1795
|
|
|
public function testRenderTestClassForClassWithoutInterface() |
1796
|
|
|
{ |
1797
|
|
|
$class = $this->initDataFromYamlAndGetSecondClassWithoutInterface(); |
1798
|
|
|
$result = $this->getRenderer()->render($class->getTestClass()); |
1799
|
|
|
$this->assertEquals($this->postTestClassWithoutInterface, $result); |
1800
|
|
|
} |
1801
|
|
|
|
1802
|
|
|
/** |
1803
|
|
|
* @return array |
1804
|
|
|
*/ |
1805
|
|
|
public function dataForTestRenderAndPutItemsToContent() |
1806
|
|
|
{ |
1807
|
|
|
return [ |
1808
|
|
|
[$this->postClassExpected, $this->postClassWithNewPropertyExpected, 41], |
1809
|
|
|
]; |
1810
|
|
|
} |
1811
|
|
|
|
1812
|
|
|
/** |
1813
|
|
|
* @return array |
1814
|
|
|
*/ |
1815
|
|
|
public function dataForTestRenderAndPutConstructorBodyToContent() |
1816
|
|
|
{ |
1817
|
|
|
return [ |
1818
|
|
|
[$this->postClassExpected, $this->postClassWithUpdatedConstructor, 47] |
1819
|
|
|
]; |
1820
|
|
|
} |
1821
|
|
|
|
1822
|
|
|
/** |
1823
|
|
|
* @return ClassManager |
1824
|
|
|
*/ |
1825
|
|
|
protected function initDataFromYamlAndGetSecondClassWithoutInterface() |
1826
|
|
|
{ |
1827
|
|
|
$classConfig = new ClassConfig(); |
1828
|
|
|
$classConfig->setNoInterface(true); |
1829
|
|
|
$classManagers = $this->generateDataFromYamlHelper($classConfig); |
1830
|
|
|
return $classManagers[1]; |
1831
|
|
|
} |
1832
|
|
|
|
1833
|
|
|
protected function generateDataFromYamlHelper(ClassConfig $classConfig = null) |
1834
|
|
|
{ |
1835
|
|
|
return $this->generateClassManagersFromYaml(Helper::getStructureYaml(), $classConfig); |
1836
|
|
|
} |
1837
|
|
|
|
1838
|
|
|
protected function generateClassManagersFromYaml($yaml, ClassConfig $classConfig = null) |
1839
|
|
|
{ |
1840
|
|
|
self::bootKernel(); |
1841
|
|
|
$structureGenerator = self::$kernel->getContainer()->get('seg.structure_generator'); |
1842
|
|
|
return $structureGenerator->buildEntitiesClassStructure($structureGenerator->parseToArray($yaml), $classConfig); |
1843
|
|
|
} |
1844
|
|
|
|
1845
|
|
|
protected function getRenderer() |
1846
|
|
|
{ |
1847
|
|
|
self::bootKernel(); |
1848
|
|
|
return self::$kernel->getContainer()->get('seg.renderer'); |
1849
|
|
|
} |
1850
|
|
|
} |
1851
|
|
|
|