GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a48bd8...83d092 )
by joseph
16:18 queued 18s
created

replaceNamespaceBackToStandard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Medium\CodeGeneration\Creation\Src\Entity\DataTransferObjects;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\CodeHelper;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\DataTransferObjects\DtoCreator;
7
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FileFactory;
8
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FindReplaceFactory;
9
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File;
10
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File\Writer;
11
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper;
12
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\ReflectionHelper;
13
use EdmondsCommerce\DoctrineStaticMeta\Config;
14
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
15
use EdmondsCommerce\DoctrineStaticMeta\Tests\Small\ConfigTest;
16
17
/**
18
 * @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\DataTransferObjects\DtoCreator
19
 * @medium
20
 */
21
class DataTransferObjectCreatorTest extends AbstractTest
22
{
23
    public const WORK_DIR = self::VAR_PATH . '/' . self::TEST_TYPE_MEDIUM . '/DataTransferObjectCreatorTest';
24
// phpcs:disable
25
    private const DTO = <<<'PHP'
26
<?php declare(strict_types=1);
27
// phpcs:disable Generic.Files.LineLength.TooLong
28
namespace My\Test\Project\Entity\DataTransferObjects;
29
30
use Doctrine\Common\Collections\ArrayCollection;
31
use EdmondsCommerce\DoctrineStaticMeta\Entity\Debug\DebugEntityDataObjectIds;
32
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\DataTransferObjectInterface;
33
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
34
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
35
use Ramsey\Uuid\UuidInterface;
36
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
37
use My\Test\Project\Entities\Person;
38
39
/**
40
 * This data transfer object should be used to hold potentially unvalidated update data,
41
 * ready to be fed into the Entity::update method
42
 *
43
 * You can choose to validate the DTO, but it the Entity will still be validated at the Entity::update stage
44
 *
45
 * Entity Properties use a single class property which can be either
46
 * - DataTransferObjectInterface
47
 * - EntityInterface
48
 *
49
 * This class should never have any logic beyond getters and setters
50
 * @SuppressWarnings(PHPMD)
51
 */
52
final class PersonDto implements DataTransferObjectInterface
53
{
54
55
    /**
56
     * These are required imports that we have in this comment to prevent PHPStorm from removing them
57
     *
58
     * @see ArrayCollection
59
     * @see EntityInterface
60
     */
61
62
    use DebugEntityDataObjectIds;
63
64
    public const ENTITY_FQN = Person::class;
65
66
    /**
67
     * @var \Ramsey\Uuid\UuidInterface
68
     */
69
    private $id;
70
71
    /**
72
     * This method is called by the Symfony validation component when loading the meta data
73
     *
74
     * In this method, we pass the meta data through to the Entity so that it can be configured
75
     *
76
     * @param ValidatorClassMetaData $metadata
77
     *
78
     * @throws DoctrineStaticMetaException
79
     */
80
    public static function loadValidatorMetaData(ValidatorClassMetaData $metadata): void
81
    {
82
        Person::loadValidatorMetaData($metadata);
83
    }
84
85
    public static function getEntityFqn(): string
86
    {
87
        return self::ENTITY_FQN;
88
    }
89
90
    public function getId(): UuidInterface
91
    {
92
        return $this->id;
93
    }
94
95
    public function setId(UuidInterface $id): self
96
    {
97
        $this->id = $id;
98
        $this->initDebugIds(true);
99
100
        return $this;
101
    }
102
103
104
    /**
105
     * @var ?\DateTime
106
     */
107
    private $datetime = Person::DEFAULT_DATETIME;
108
109
    /**
110
     * @var ?bool
111
     */
112
    private $boolean = Person::DEFAULT_BOOLEAN;
113
114
    /**
115
     * @var ?float
116
     */
117
    private $float = Person::DEFAULT_FLOAT;
118
119
    /**
120
     * @var ?int
121
     */
122
    private $integer = Person::DEFAULT_INTEGER;
123
124
    /**
125
     * @var ?string
126
     */
127
    private $json = Person::DEFAULT_JSON;
128
129
    /**
130
     * @var ?string
131
     */
132
    private $string = Person::DEFAULT_STRING;
133
134
    /**
135
     * @var ?string
136
     */
137
    private $text = Person::DEFAULT_TEXT;
138
139
    /**
140
     * @var \Doctrine\Common\Collections\Collection
141
     */
142
    private $attributesEmails = null;
143
144
    /**
145
     * @var null|\My\Test\Project\Entity\Interfaces\Attributes\AddressInterface|\My\Test\Project\Entity\DataTransferObjects\Attributes\AddressDto
146
     */
147
    private $attributesAddress = null;
148
149
    /**
150
     * @var null|\My\Test\Project\Entity\Interfaces\Company\DirectorInterface|\My\Test\Project\Entity\DataTransferObjects\Company\DirectorDto
151
     */
152
    private $companyDirector = null;
153
154
    /**
155
     * @var null|\My\Test\Project\Entity\Interfaces\Large\RelationInterface|\My\Test\Project\Entity\DataTransferObjects\Large\RelationDto
156
     */
157
    private $largeRelation = null;
158
159
    /**
160
     */
161
    private $decimal = Person::DEFAULT_DECIMAL;
162
163
164
    public function getAttributesAddress(): ?\My\Test\Project\Entity\Interfaces\Attributes\AddressInterface
165
    {
166
        if(null === $this->attributesAddress){
167
            return $this->attributesAddress;
168
        }
169
        if($this->attributesAddress instanceof \My\Test\Project\Entity\Interfaces\Attributes\AddressInterface){
170
            return $this->attributesAddress;
171
        }
172
        throw new \RuntimeException(
173
            '$this->attributesAddress is not an Entity, but is '. \get_class($this->attributesAddress)
174
        );
175
    }
176
177
178
    public function getAttributesAddressDto(): ?\My\Test\Project\Entity\DataTransferObjects\Attributes\AddressDto
179
    {
180
        if(null === $this->attributesAddress){
181
            return $this->attributesAddress;
182
        }
183
        if($this->attributesAddress instanceof \My\Test\Project\Entity\DataTransferObjects\Attributes\AddressDto){
184
            return $this->attributesAddress;
185
        }
186
        throw new \RuntimeException(
187
            '$this->attributesAddress is not a DTO, but is '. \get_class($this->attributesAddress)
188
        );
189
    }
190
191
192
    public function getAttributesEmails(): \Doctrine\Common\Collections\Collection
193
    {
194
        return $this->attributesEmails ?? $this->attributesEmails = new ArrayCollection();
195
    }
196
197
198
    public function getCompanyDirector(): ?\My\Test\Project\Entity\Interfaces\Company\DirectorInterface
199
    {
200
        if(null === $this->companyDirector){
201
            return $this->companyDirector;
202
        }
203
        if($this->companyDirector instanceof \My\Test\Project\Entity\Interfaces\Company\DirectorInterface){
204
            return $this->companyDirector;
205
        }
206
        throw new \RuntimeException(
207
            '$this->companyDirector is not an Entity, but is '. \get_class($this->companyDirector)
208
        );
209
    }
210
211
212
    public function getCompanyDirectorDto(): ?\My\Test\Project\Entity\DataTransferObjects\Company\DirectorDto
213
    {
214
        if(null === $this->companyDirector){
215
            return $this->companyDirector;
216
        }
217
        if($this->companyDirector instanceof \My\Test\Project\Entity\DataTransferObjects\Company\DirectorDto){
218
            return $this->companyDirector;
219
        }
220
        throw new \RuntimeException(
221
            '$this->companyDirector is not a DTO, but is '. \get_class($this->companyDirector)
222
        );
223
    }
224
225
226
    public function getDatetime(): ?\DateTime
227
    {
228
        return $this->datetime;
229
    }
230
231
232
    public function getDecimal()
233
    {
234
        return $this->decimal;
235
    }
236
237
238
    public function getFloat(): ?float
239
    {
240
        return $this->float;
241
    }
242
243
244
    public function getInteger(): ?int
245
    {
246
        return $this->integer;
247
    }
248
249
250
    public function getJson(): ?string
251
    {
252
        return $this->json;
253
    }
254
255
256
    public function getLargeRelation(): ?\My\Test\Project\Entity\Interfaces\Large\RelationInterface
257
    {
258
        if(null === $this->largeRelation){
259
            return $this->largeRelation;
260
        }
261
        if($this->largeRelation instanceof \My\Test\Project\Entity\Interfaces\Large\RelationInterface){
262
            return $this->largeRelation;
263
        }
264
        throw new \RuntimeException(
265
            '$this->largeRelation is not an Entity, but is '. \get_class($this->largeRelation)
266
        );
267
    }
268
269
270
    public function getLargeRelationDto(): ?\My\Test\Project\Entity\DataTransferObjects\Large\RelationDto
271
    {
272
        if(null === $this->largeRelation){
273
            return $this->largeRelation;
274
        }
275
        if($this->largeRelation instanceof \My\Test\Project\Entity\DataTransferObjects\Large\RelationDto){
276
            return $this->largeRelation;
277
        }
278
        throw new \RuntimeException(
279
            '$this->largeRelation is not a DTO, but is '. \get_class($this->largeRelation)
280
        );
281
    }
282
283
284
    public function getString(): ?string
285
    {
286
        return $this->string;
287
    }
288
289
290
    public function getText(): ?string
291
    {
292
        return $this->text;
293
    }
294
295
296
    public function isBoolean(): ?bool
297
    {
298
        return $this->boolean;
299
    }
300
301
302
    public function issetAttributesAddressAsDto(): bool
303
    {
304
        return $this->attributesAddress instanceof DataTransferObjectInterface;
305
    }
306
307
308
    public function issetAttributesAddressAsEntity(): bool
309
    {
310
        return $this->attributesAddress instanceof EntityInterface;
311
    }
312
313
314
    public function issetCompanyDirectorAsDto(): bool
315
    {
316
        return $this->companyDirector instanceof DataTransferObjectInterface;
317
    }
318
319
320
    public function issetCompanyDirectorAsEntity(): bool
321
    {
322
        return $this->companyDirector instanceof EntityInterface;
323
    }
324
325
326
    public function issetLargeRelationAsDto(): bool
327
    {
328
        return $this->largeRelation instanceof DataTransferObjectInterface;
329
    }
330
331
332
    public function issetLargeRelationAsEntity(): bool
333
    {
334
        return $this->largeRelation instanceof EntityInterface;
335
    }
336
337
338
    public function setAttributesAddress(?\My\Test\Project\Entity\Interfaces\Attributes\AddressInterface $attributesAddress): self 
339
    {
340
        $this->attributesAddress = $attributesAddress;
341
        return $this;
342
    }
343
344
345
    public function setAttributesAddressDto(?\My\Test\Project\Entity\DataTransferObjects\Attributes\AddressDto $attributesAddress): self 
346
    {
347
        $this->attributesAddress = $attributesAddress;
348
        return $this;
349
    }
350
351
352
    public function setAttributesEmails(\Doctrine\Common\Collections\Collection $attributesEmails): self 
353
    {
354
        $this->attributesEmails = $attributesEmails;
355
        return $this;
356
    }
357
358
359
    public function setBoolean(?bool $boolean): self 
360
    {
361
        $this->boolean = $boolean;
362
        return $this;
363
    }
364
365
366
    public function setCompanyDirector(?\My\Test\Project\Entity\Interfaces\Company\DirectorInterface $companyDirector): self 
367
    {
368
        $this->companyDirector = $companyDirector;
369
        return $this;
370
    }
371
372
373
    public function setCompanyDirectorDto(?\My\Test\Project\Entity\DataTransferObjects\Company\DirectorDto $companyDirector): self 
374
    {
375
        $this->companyDirector = $companyDirector;
376
        return $this;
377
    }
378
379
380
    public function setDatetime(?\DateTime $datetime): self 
381
    {
382
        $this->datetime = $datetime;
383
        return $this;
384
    }
385
386
387
    public function setDecimal( $decimal): self 
388
    {
389
        $this->decimal = $decimal;
390
        return $this;
391
    }
392
393
394
    public function setFloat(?float $float): self 
395
    {
396
        $this->float = $float;
397
        return $this;
398
    }
399
400
401
    public function setInteger(?int $integer): self 
402
    {
403
        $this->integer = $integer;
404
        return $this;
405
    }
406
407
408
    public function setJson(?string $json): self 
409
    {
410
        $this->json = $json;
411
        return $this;
412
    }
413
414
415
    public function setLargeRelation(?\My\Test\Project\Entity\Interfaces\Large\RelationInterface $largeRelation): self 
416
    {
417
        $this->largeRelation = $largeRelation;
418
        return $this;
419
    }
420
421
422
    public function setLargeRelationDto(?\My\Test\Project\Entity\DataTransferObjects\Large\RelationDto $largeRelation): self 
423
    {
424
        $this->largeRelation = $largeRelation;
425
        return $this;
426
    }
427
428
429
    public function setString(?string $string): self 
430
    {
431
        $this->string = $string;
432
        return $this;
433
    }
434
435
436
    public function setText(?string $text): self 
437
    {
438
        $this->text = $text;
439
        return $this;
440
    }
441
442
}
443
PHP;
444
445
446
    private const NESTED_DTO = <<<'PHP'
447
<?php declare(strict_types=1);
448
// phpcs:disable Generic.Files.LineLength.TooLong
449
namespace My\Test\Project\Entity\DataTransferObjects\Another\Deeply\Nested;
450
451
use Doctrine\Common\Collections\ArrayCollection;
452
use EdmondsCommerce\DoctrineStaticMeta\Entity\Debug\DebugEntityDataObjectIds;
453
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\DataTransferObjectInterface;
454
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
455
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
456
use Ramsey\Uuid\UuidInterface;
457
use Symfony\Component\Validator\Mapping\ClassMetadata as ValidatorClassMetaData;
458
use My\Test\Project\Entities\Another\Deeply\Nested\Client;
459
460
/**
461
 * This data transfer object should be used to hold potentially unvalidated update data,
462
 * ready to be fed into the Entity::update method
463
 *
464
 * You can choose to validate the DTO, but it the Entity will still be validated at the Entity::update stage
465
 *
466
 * Entity Properties use a single class property which can be either
467
 * - DataTransferObjectInterface
468
 * - EntityInterface
469
 *
470
 * This class should never have any logic beyond getters and setters
471
 * @SuppressWarnings(PHPMD)
472
 */
473
final class ClientDto implements DataTransferObjectInterface
474
{
475
476
    /**
477
     * These are required imports that we have in this comment to prevent PHPStorm from removing them
478
     *
479
     * @see ArrayCollection
480
     * @see EntityInterface
481
     */
482
483
    use DebugEntityDataObjectIds;
484
485
    public const ENTITY_FQN = Client::class;
486
487
    /**
488
     * @var \Ramsey\Uuid\UuidInterface
489
     */
490
    private $id;
491
492
    /**
493
     * This method is called by the Symfony validation component when loading the meta data
494
     *
495
     * In this method, we pass the meta data through to the Entity so that it can be configured
496
     *
497
     * @param ValidatorClassMetaData $metadata
498
     *
499
     * @throws DoctrineStaticMetaException
500
     */
501
    public static function loadValidatorMetaData(ValidatorClassMetaData $metadata): void
502
    {
503
        Client::loadValidatorMetaData($metadata);
504
    }
505
506
    public static function getEntityFqn(): string
507
    {
508
        return self::ENTITY_FQN;
509
    }
510
511
    public function getId(): UuidInterface
512
    {
513
        return $this->id;
514
    }
515
516
    public function setId(UuidInterface $id): self
517
    {
518
        $this->id = $id;
519
        $this->initDebugIds(true);
520
521
        return $this;
522
    }
523
524
525
    /**
526
     * @var ?\DateTime
527
     */
528
    private $datetime = Client::DEFAULT_DATETIME;
529
530
    /**
531
     * @var ?bool
532
     */
533
    private $boolean = Client::DEFAULT_BOOLEAN;
534
535
    /**
536
     * @var ?float
537
     */
538
    private $float = Client::DEFAULT_FLOAT;
539
540
    /**
541
     * @var ?int
542
     */
543
    private $integer = Client::DEFAULT_INTEGER;
544
545
    /**
546
     * @var ?string
547
     */
548
    private $json = Client::DEFAULT_JSON;
549
550
    /**
551
     * @var ?string
552
     */
553
    private $string = Client::DEFAULT_STRING;
554
555
    /**
556
     * @var ?string
557
     */
558
    private $text = Client::DEFAULT_TEXT;
559
560
    /**
561
     * @var null|\My\Test\Project\Entity\Interfaces\CompanyInterface|\My\Test\Project\Entity\DataTransferObjects\CompanyDto
562
     */
563
    private $company = null;
564
565
    /**
566
     */
567
    private $decimal = Client::DEFAULT_DECIMAL;
568
569
570
    public function getCompany(): ?\My\Test\Project\Entity\Interfaces\CompanyInterface
571
    {
572
        if(null === $this->company){
573
            return $this->company;
574
        }
575
        if($this->company instanceof \My\Test\Project\Entity\Interfaces\CompanyInterface){
576
            return $this->company;
577
        }
578
        throw new \RuntimeException(
579
            '$this->company is not an Entity, but is '. \get_class($this->company)
580
        );
581
    }
582
583
584
    public function getCompanyDto(): ?\My\Test\Project\Entity\DataTransferObjects\CompanyDto
585
    {
586
        if(null === $this->company){
587
            return $this->company;
588
        }
589
        if($this->company instanceof \My\Test\Project\Entity\DataTransferObjects\CompanyDto){
590
            return $this->company;
591
        }
592
        throw new \RuntimeException(
593
            '$this->company is not a DTO, but is '. \get_class($this->company)
594
        );
595
    }
596
597
598
    public function getDatetime(): ?\DateTime
599
    {
600
        return $this->datetime;
601
    }
602
603
604
    public function getDecimal()
605
    {
606
        return $this->decimal;
607
    }
608
609
610
    public function getFloat(): ?float
611
    {
612
        return $this->float;
613
    }
614
615
616
    public function getInteger(): ?int
617
    {
618
        return $this->integer;
619
    }
620
621
622
    public function getJson(): ?string
623
    {
624
        return $this->json;
625
    }
626
627
628
    public function getString(): ?string
629
    {
630
        return $this->string;
631
    }
632
633
634
    public function getText(): ?string
635
    {
636
        return $this->text;
637
    }
638
639
640
    public function isBoolean(): ?bool
641
    {
642
        return $this->boolean;
643
    }
644
645
646
    public function issetCompanyAsDto(): bool
647
    {
648
        return $this->company instanceof DataTransferObjectInterface;
649
    }
650
651
652
    public function issetCompanyAsEntity(): bool
653
    {
654
        return $this->company instanceof EntityInterface;
655
    }
656
657
658
    public function setBoolean(?bool $boolean): self 
659
    {
660
        $this->boolean = $boolean;
661
        return $this;
662
    }
663
664
665
    public function setCompany(?\My\Test\Project\Entity\Interfaces\CompanyInterface $company): self 
666
    {
667
        $this->company = $company;
668
        return $this;
669
    }
670
671
672
    public function setCompanyDto(?\My\Test\Project\Entity\DataTransferObjects\CompanyDto $company): self 
673
    {
674
        $this->company = $company;
675
        return $this;
676
    }
677
678
679
    public function setDatetime(?\DateTime $datetime): self 
680
    {
681
        $this->datetime = $datetime;
682
        return $this;
683
    }
684
685
686
    public function setDecimal( $decimal): self 
687
    {
688
        $this->decimal = $decimal;
689
        return $this;
690
    }
691
692
693
    public function setFloat(?float $float): self 
694
    {
695
        $this->float = $float;
696
        return $this;
697
    }
698
699
700
    public function setInteger(?int $integer): self 
701
    {
702
        $this->integer = $integer;
703
        return $this;
704
    }
705
706
707
    public function setJson(?string $json): self 
708
    {
709
        $this->json = $json;
710
        return $this;
711
    }
712
713
714
    public function setString(?string $string): self 
715
    {
716
        $this->string = $string;
717
        return $this;
718
    }
719
720
721
    public function setText(?string $text): self 
722
    {
723
        $this->text = $text;
724
        return $this;
725
    }
726
727
}
728
PHP;
729
730
// phpcs:enable
731
    protected static $buildOnce = true;
732
733
    public function setup()
734
    {
735
        parent::setUp();
736
        if (false === self::$built) {
737
            $this->getTestCodeGenerator()
738
                 ->copyTo(self::WORK_DIR);
739
            self::$built = true;
740
        }
741
        $this->setupCopiedWorkDir();
742
    }
743
744
    /**
745
     * @test
746
     */
747
    public function itCanCreateADto(): void
748
    {
749
        $newObjectFqn = $this->getCopiedFqn(
750
            self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entity\\DataTransferObjects\\PersonDto'
751
        );
752
        $file         = $this->getCreator()->createTargetFileObject($newObjectFqn)->getTargetFile();
753
        $expected     = self::DTO;
754
        $actual       = $this->replaceNamespaceBackToStandard($file);
755
        self::assertSame($expected, $actual);
756
    }
757
758
    private function getCreator(): DtoCreator
759
    {
760
        $namespaceHelper = new NamespaceHelper();
761
        $config          = new Config(ConfigTest::SERVER);
762
763
        $creator = new DtoCreator(
764
            new FileFactory($namespaceHelper, $config),
765
            $namespaceHelper,
766
            new Writer(),
767
            $config,
768
            new FindReplaceFactory(),
769
            new ReflectionHelper($namespaceHelper),
770
            new CodeHelper($namespaceHelper)
771
        );
772
        $creator->setProjectRootNamespace(ltrim($this->getCopiedFqn(self::TEST_PROJECT_ROOT_NAMESPACE), '\\'));
773
        $creator->setProjectRootDirectory($this->copiedWorkDir);
0 ignored issues
show
Bug introduced by
It seems like $this->copiedWorkDir can also be of type null; however, parameter $projectRootDirectory of EdmondsCommerce\Doctrine...tProjectRootDirectory() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

773
        $creator->setProjectRootDirectory(/** @scrutinizer ignore-type */ $this->copiedWorkDir);
Loading history...
774
775
        return $creator;
776
    }
777
778
    private function replaceNamespaceBackToStandard(File $file): string
779
    {
780
        return \str_replace(
781
            ltrim($this->getCopiedFqn('My\\Test\\Project'), '\\'),
782
            'My\\Test\\Project\\',
783
            $file->getContents()
784
        );
785
    }
786
787
    /**
788
     * @test
789
     */
790
    public function itCanCreateADtoFromAnEntityFqn(): void
791
    {
792
        $entityFqn = $this->getCopiedFqn(
793
            self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entities\\Person'
794
        );
795
        $file      = $this->getCreator()
796
                          ->setNewObjectFqnFromEntityFqn($entityFqn)
797
                          ->createTargetFileObject()
798
                          ->getTargetFile();
799
        $expected  = self::DTO;
800
        $actual    = $this->replaceNamespaceBackToStandard($file);
801
        self::assertSame($expected, $actual);
802
    }
803
804
    /**
805
     * @test
806
     */
807
    public function itCanCreateANestedDto(): void
808
    {
809
        $newObjectFqn = $this->getCopiedFqn(
810
            self::TEST_PROJECT_ROOT_NAMESPACE .
811
            '\\Entity\\DataTransferObjects\\Another\\Deeply\\Nested\\ClientDto'
812
        );
813
        $file         = $this->getCreator()->createTargetFileObject($newObjectFqn)->getTargetFile();
814
        $expected     = self::NESTED_DTO;
815
        $actual       = $this->replaceNamespaceBackToStandard($file);
816
        self::assertSame($expected, $actual);
817
    }
818
819
    /**
820
     * @test
821
     */
822
    public function itCanCreateANestedDtoFromEntityFqn(): void
823
    {
824
        $entityFqn = $this->getCopiedFqn(
825
            self::TEST_PROJECT_ROOT_NAMESPACE .
826
            '\\Entities\\Another\\Deeply\\Nested\\Client'
827
        );
828
        $file      = $this->getCreator()
829
                          ->setNewObjectFqnFromEntityFqn($entityFqn)
830
                          ->createTargetFileObject()
831
                          ->getTargetFile();
832
        $expected  = self::NESTED_DTO;
833
        $actual    = $this->replaceNamespaceBackToStandard($file);
834
        self::assertSame($expected, $actual);
835
    }
836
}
837