|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\E\CodeGeneration\Action; |
|
4
|
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Action\CreateDtosForAllEntitiesAction; |
|
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\CodeHelper; |
|
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\DataTransferObjects\DtoCreator; |
|
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FileFactory; |
|
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FindReplaceFactory; |
|
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\Action\CreateDtosForAllEntitiesAction |
|
19
|
|
|
* @large |
|
20
|
|
|
*/ |
|
21
|
|
|
class CreateDataTransferObjectsForAllEntitiesActionTest extends AbstractTest |
|
22
|
|
|
{ |
|
23
|
|
|
public const WORK_DIR = self::VAR_PATH . '/' . self::TEST_TYPE_LARGE . |
|
24
|
|
|
'/CreateDataTransferObjectsForAllEntitiesActionTest'; |
|
25
|
|
|
|
|
26
|
|
|
protected static $buildOnce = true; |
|
27
|
|
|
|
|
28
|
|
|
public function setup() |
|
29
|
|
|
{ |
|
30
|
|
|
parent::setUp(); |
|
31
|
|
|
if (false === self::$built) { |
|
32
|
|
|
$this->getTestCodeGenerator() |
|
33
|
|
|
->copyTo(self::WORK_DIR); |
|
34
|
|
|
$this->getFileSystem()->remove(self::WORK_DIR . '/src/Entity/DataTransferObjects'); |
|
35
|
|
|
self::$built = true; |
|
36
|
|
|
} |
|
37
|
|
|
$this->setupCopiedWorkDir(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @test |
|
42
|
|
|
*/ |
|
43
|
|
|
public function itCanCreateDtosForAllEntities(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->getAction()->run(); |
|
46
|
|
|
self::assertFileExists($this->copiedWorkDir . '/src/Entity/DataTransferObjects/PersonDto.php'); |
|
47
|
|
|
$this->qaGeneratedCode(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
private function getAction(): CreateDtosForAllEntitiesAction |
|
51
|
|
|
{ |
|
52
|
|
|
$namespaceHelper = new NamespaceHelper(); |
|
53
|
|
|
$config = new Config(ConfigTest::SERVER); |
|
54
|
|
|
|
|
55
|
|
|
$creator = new DtoCreator( |
|
56
|
|
|
new FileFactory($namespaceHelper, $config), |
|
57
|
|
|
$namespaceHelper, |
|
58
|
|
|
new Writer(), |
|
59
|
|
|
$config, |
|
60
|
|
|
new FindReplaceFactory(), |
|
61
|
|
|
new ReflectionHelper($namespaceHelper), |
|
62
|
|
|
new CodeHelper($namespaceHelper) |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
$action = new CreateDtosForAllEntitiesAction($creator, $namespaceHelper); |
|
66
|
|
|
$action->setProjectRootNamespace($this->copiedRootNamespace); |
|
|
|
|
|
|
67
|
|
|
$action->setProjectRootDirectory($this->copiedWorkDir); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
return $action; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @test |
|
74
|
|
|
*/ |
|
75
|
|
|
public function itCanBeRunMultipleTimes(): void |
|
76
|
|
|
{ |
|
77
|
|
|
$this->getAction()->run(); |
|
78
|
|
|
$this->getAction()->run(); |
|
79
|
|
|
self::assertFileExists($this->copiedWorkDir . '/src/Entity/DataTransferObjects/PersonDto.php'); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|