1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Medium\CodeGeneration\Action; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Action\CreateEmbeddableAction; |
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @medium |
10
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Action\CreateEmbeddableAction |
11
|
|
|
*/ |
12
|
|
|
class CreateEmbeddableActionTest extends AbstractTest |
13
|
|
|
{ |
14
|
|
|
public const WORK_DIR = self::VAR_PATH . '/' . self::TEST_TYPE_MEDIUM . '/CreateEmbeddableActionTest'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var CreateEmbeddableAction |
18
|
|
|
*/ |
19
|
|
|
private $action; |
20
|
|
|
|
21
|
|
|
public function setUp() |
22
|
|
|
{ |
23
|
|
|
parent::setUp(); |
24
|
|
|
$this->generateTestCode(); |
25
|
|
|
$this->setupCopiedWorkDir(); |
26
|
|
|
$this->action = $this->container->get(CreateEmbeddableAction::class); |
27
|
|
|
$this->action->setProjectRootDirectory($this->copiedWorkDir) |
28
|
|
|
->setProjectRootNamespace($this->copiedRootNamespace); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @test |
33
|
|
|
*/ |
34
|
|
|
public function itCanCreateASkeleton(): void |
35
|
|
|
{ |
36
|
|
|
$this->action->setCatName('Food') |
37
|
|
|
->setName('Cheese') |
38
|
|
|
->run(); |
39
|
|
|
|
40
|
|
|
$expectedPaths = [ |
41
|
|
|
'src/Entity/Embeddable/FakerData/Food/CheeseEmbeddableFakerData.php', |
42
|
|
|
'src/Entity/Embeddable/Interfaces/Objects/Food/CheeseEmbeddableInterface.php', |
43
|
|
|
'src/Entity/Embeddable/Interfaces/Food/HasCheeseEmbeddableInterface.php', |
44
|
|
|
'src/Entity/Embeddable/Objects/Food/CheeseEmbeddable.php', |
45
|
|
|
'src/Entity/Embeddable/Traits/Food/HasCheeseEmbeddableTrait.php', |
46
|
|
|
]; |
47
|
|
|
foreach ($expectedPaths as $path) { |
48
|
|
|
self::assertFileExists($this->copiedWorkDir . $path); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @test |
54
|
|
|
*/ |
55
|
|
|
public function itThrowsExceptionIfNoCatName(): void |
56
|
|
|
{ |
57
|
|
|
$this->expectException(\RuntimeException::class); |
58
|
|
|
$this->action->setName('Cheese') |
59
|
|
|
->run(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @test |
64
|
|
|
*/ |
65
|
|
|
public function itThrowsExceptionIfNoName(): void |
66
|
|
|
{ |
67
|
|
|
$this->expectException(\RuntimeException::class); |
68
|
|
|
$this->action->setCatName('Cheese') |
69
|
|
|
->run(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |