@@ -70,8 +70,7 @@ public function getFriends(): Collection
70
70
{
71
71
return $this->friends;
72
72
}
73
- PHP
74
- , $ person );
73
+ PHP, $ person );
75
74
}
76
75
77
76
public function testCustomAttributes (): void
@@ -106,29 +105,24 @@ public function testCustomAttributes(): void
106
105
#[MyAttribute]
107
106
class Book
108
107
{
109
- PHP
110
- , $ book );
108
+ PHP, $ book );
111
109
112
110
// Attributes given as unordered map.
113
111
$ this ->assertStringContainsString (<<<'PHP'
114
112
#[ORM\OneToMany(targetEntity: 'App\Entity\Review', mappedBy: 'book', cascade: ['persist', 'remove'])]
115
- PHP
116
- , $ book );
113
+ PHP, $ book );
117
114
$ this ->assertStringContainsString (<<<'PHP'
118
115
#[ORM\OrderBy(name: 'ASC')]
119
- PHP
120
- , $ book );
116
+ PHP, $ book );
121
117
// Generated attribute could be merged with next one that is a configured one.
122
118
$ this ->assertStringContainsString (<<<'PHP'
123
119
#[ORM\InverseJoinColumn(nullable: false, unique: true, name: 'first_join_column')]
124
- PHP
125
- , $ book );
120
+ PHP, $ book );
126
121
// Configured attribute could not be merged with next one and it is treated
127
122
// as repeated.
128
123
$ this ->assertStringContainsString (<<<'PHP'
129
124
#[ORM\InverseJoinColumn(name: 'second_join_column')]
130
- PHP
131
- , $ book );
125
+ PHP, $ book );
132
126
}
133
127
134
128
public function testFluentMutators (): void
@@ -147,8 +141,7 @@ public function setUrl(?string $url): self
147
141
148
142
return $this;
149
143
}
150
- PHP
151
- , $ person );
144
+ PHP, $ person );
152
145
153
146
$ this ->assertStringContainsString (<<<'PHP'
154
147
public function addFriend(Person $friend): self
@@ -164,8 +157,7 @@ public function removeFriend(Person $friend): self
164
157
165
158
return $this;
166
159
}
167
- PHP
168
- , $ person );
160
+ PHP, $ person );
169
161
}
170
162
171
163
public function testDoNotGenerateAccessorMethods (): void
@@ -230,8 +222,7 @@ public function testPropertyDefault(): void
230
222
231
223
$ this ->assertStringContainsString (<<<'PHP'
232
224
private string $availability = 'https://schema.org/InStock';
233
- PHP
234
- , $ book );
225
+ PHP, $ book );
235
226
}
236
227
237
228
public function testReadableWritable (): void
@@ -274,16 +265,14 @@ public function testGeneratedId(): void
274
265
#[ORM\GeneratedValue(strategy: 'AUTO')]
275
266
#[ORM\Column(type: 'integer')]
276
267
private ?int $id = null;
277
- PHP
278
- , $ person );
268
+ PHP, $ person );
279
269
280
270
$ this ->assertStringContainsString (<<<'PHP'
281
271
public function getId(): ?int
282
272
{
283
273
return $this->id;
284
274
}
285
- PHP
286
- , $ person );
275
+ PHP, $ person );
287
276
288
277
$ this ->assertStringNotContainsString ('setId( ' , $ person );
289
278
}
@@ -304,24 +293,21 @@ public function testNonGeneratedId(): void
304
293
#[ORM\Id]
305
294
#[ORM\Column(type: 'string')]
306
295
private string $id;
307
- PHP
308
- , $ person );
296
+ PHP, $ person );
309
297
310
298
$ this ->assertStringContainsString (<<<'PHP'
311
299
public function getId(): string
312
300
{
313
301
return $this->id;
314
302
}
315
- PHP
316
- , $ person );
303
+ PHP, $ person );
317
304
318
305
$ this ->assertStringContainsString (<<<'PHP'
319
306
public function setId(string $id): void
320
307
{
321
308
$this->id = $id;
322
309
}
323
- PHP
324
- , $ person );
310
+ PHP, $ person );
325
311
}
326
312
327
313
public function testGeneratedUuid (): void
@@ -342,16 +328,14 @@ public function testGeneratedUuid(): void
342
328
#[ORM\Column(type: 'guid')]
343
329
#[Assert\Uuid]
344
330
private ?string $id = null;
345
- PHP
346
- , $ person );
331
+ PHP, $ person );
347
332
348
333
$ this ->assertStringContainsString (<<<'PHP'
349
334
public function getId(): ?string
350
335
{
351
336
return $this->id;
352
337
}
353
- PHP
354
- , $ person );
338
+ PHP, $ person );
355
339
356
340
$ this ->assertStringNotContainsString ('setId( ' , $ person );
357
341
}
@@ -373,25 +357,22 @@ public function testNonGeneratedUuid(): void
373
357
#[ORM\Column(type: 'guid')]
374
358
#[Assert\Uuid]
375
359
private string $id;
376
- PHP
377
- , $ person );
360
+ PHP, $ person );
378
361
379
362
$ this ->assertStringContainsString (<<<'PHP'
380
363
public function getId(): string
381
364
{
382
365
return $this->id;
383
366
}
384
- PHP
385
- , $ person );
367
+ PHP, $ person );
386
368
387
369
$ this ->assertStringContainsString (<<<'PHP'
388
370
public function setId(string $id): void
389
371
{
390
372
$this->id = $id;
391
373
}
392
374
393
- PHP
394
- , $ person );
375
+ PHP, $ person );
395
376
}
396
377
397
378
public function testDoNotGenerateId (): void
@@ -463,8 +444,7 @@ public function testGeneratedEnum(): void
463
444
$ this ->assertStringContainsString (<<<'PHP'
464
445
/** @var string The female gender. */
465
446
public const FEMALE = 'https://schema.org/Female';
466
- PHP
467
- , $ gender );
447
+ PHP, $ gender );
468
448
469
449
$ this ->assertStringNotContainsString ('function setId( ' , $ gender );
470
450
}
@@ -490,8 +470,7 @@ public function testSupersededProperties(): void
490
470
#[ORM\Column(type: 'text', nullable: true)]
491
471
#[ApiProperty(types: ['https://schema.org/award'])]
492
472
private ?string $award = null;
493
- PHP
494
- , $ creativeWork );
473
+ PHP, $ creativeWork );
495
474
496
475
$ this ->assertStringNotContainsString ('protected ' , $ creativeWork );
497
476
}
@@ -517,8 +496,7 @@ public function testActivityStreams(): void
517
496
#[ORM\Column(type: 'text', nullable: true, name: '`content`')]
518
497
#[ApiProperty(types: ['http://www.w3.org/ns/activitystreams#content'])]
519
498
private ?string $content = null;
520
- PHP
521
- , $ object );
499
+ PHP, $ object );
522
500
523
501
$ page = file_get_contents ("$ outputDir/App/Entity/Page.php " );
524
502
@@ -531,13 +509,47 @@ public function testActivityStreams(): void
531
509
#[ORM\Entity]
532
510
#[ApiResource(types: ['http://www.w3.org/ns/activitystreams#Page'], routePrefix: 'as')]
533
511
class Page extends Object_
534
- PHP
535
- , $ page );
512
+ PHP, $ page );
536
513
537
514
self ::assertFalse ($ this ->fs ->exists ("$ outputDir/App/Entity/Delete.php " ));
538
515
self ::assertFalse ($ this ->fs ->exists ("$ outputDir/App/Entity/Travel.php " ));
539
516
}
540
517
518
+ public function testGeneratedSimpleArray (): void
519
+ {
520
+ $ outputDir = __DIR__ .'/../../build/simple-array ' ;
521
+ $ config = __DIR__ .'/../config/simple-array.yaml ' ;
522
+
523
+ $ this ->fs ->mkdir ($ outputDir );
524
+
525
+ $ commandTester = new CommandTester (new GenerateCommand ());
526
+ $ this ->assertEquals (0 , $ commandTester ->execute (['output ' => $ outputDir , 'config ' => $ config ]));
527
+ $ source = file_get_contents ("$ outputDir/App/Entity/Project.php " );
528
+
529
+ $ this ->assertStringContainsString (<<<'PHP'
530
+ /**
531
+ * @see _:shareWith
532
+ */
533
+ #[ORM\Column(type: 'simple_array', nullable: true)]
534
+ #[Assert\Unique]
535
+ private ?array $shareWith = [];
536
+ PHP, $ source );
537
+
538
+ $ this ->assertStringContainsString (<<<'PHP'
539
+ public function setShareWith(?array $shareWith): void
540
+ {
541
+ $this->shareWith = $shareWith;
542
+ }
543
+
544
+ public function getShareWith(): ?array
545
+ {
546
+ return $this->shareWith;
547
+ }
548
+ PHP, $ source );
549
+ $ this ->assertStringNotContainsString ('function addShareWith ' , $ source );
550
+ $ this ->assertStringNotContainsString ('function removeShareWith ' , $ source );
551
+ }
552
+
541
553
public function testGenerationWithoutConfigFileQuestion (): void
542
554
{
543
555
// No config file is given.
0 commit comments