1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small\CodeGeneration\Creation\Src\Entity\Interfaces; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Interfaces\EntityFactoryCreator; |
|
|
|
|
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Interfaces\EntityInterfaceCreator; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FileFactory; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FindReplaceFactory; |
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File\Writer; |
10
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper; |
11
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Config; |
12
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Small\ConfigTest; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Interfaces\EntityInterfaceCreator |
17
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\AbstractCreator |
18
|
|
|
* @small |
19
|
|
|
*/ |
20
|
|
|
class EntityInterfaceCreatorTest extends TestCase |
21
|
|
|
{ |
22
|
|
|
private const INTERFACE = '<?php declare(strict_types=1); |
23
|
|
|
|
24
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces; |
25
|
|
|
|
26
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity as DSM; |
27
|
|
|
|
28
|
|
|
interface TestEntityInterface extends DSM\Interfaces\EntityInterface |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
} |
32
|
|
|
'; |
33
|
|
|
|
34
|
|
|
private const NESTED_INTERFACE = '<?php declare(strict_types=1); |
35
|
|
|
|
36
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\Super\Deeply\Nested; |
37
|
|
|
|
38
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity as DSM; |
39
|
|
|
|
40
|
|
|
interface TestEntityInterface extends DSM\Interfaces\EntityInterface |
41
|
|
|
{ |
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @test |
48
|
|
|
*/ |
49
|
|
|
public function itCanCreateANewEntityInterface(): void |
50
|
|
|
{ |
51
|
|
|
$newObjectFqn = 'EdmondsCommerce\\DoctrineStaticMeta\\Entity\\Interfaces\\TestEntityInterface'; |
52
|
|
|
$file = $this->getCreator()->createTargetFileObject($newObjectFqn)->getTargetFile(); |
53
|
|
|
$expected = self::INTERFACE; |
54
|
|
|
$actual = $file->getContents(); |
55
|
|
|
self::assertSame($expected, $actual); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
private function getCreator(): EntityInterfaceCreator |
59
|
|
|
{ |
60
|
|
|
$namespaceHelper = new NamespaceHelper(); |
61
|
|
|
$config = new Config(ConfigTest::SERVER); |
62
|
|
|
|
63
|
|
|
return new EntityInterfaceCreator( |
64
|
|
|
new FileFactory($namespaceHelper, $config), |
65
|
|
|
$namespaceHelper, |
66
|
|
|
new Writer(), |
67
|
|
|
$config, |
68
|
|
|
new FindReplaceFactory() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @test |
74
|
|
|
*/ |
75
|
|
|
public function itCanCreateANewEntityInterfaceFromEntityFqn(): void |
76
|
|
|
{ |
77
|
|
|
$entityFqn = 'EdmondsCommerce\\DoctrineStaticMeta\\Entities\\TestEntity'; |
78
|
|
|
$file = $this->getCreator() |
79
|
|
|
->setNewObjectFqnFromEntityFqn($entityFqn) |
80
|
|
|
->createTargetFileObject() |
81
|
|
|
->getTargetFile(); |
82
|
|
|
$expected = self::INTERFACE; |
83
|
|
|
$actual = $file->getContents(); |
84
|
|
|
self::assertSame($expected, $actual); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @test |
89
|
|
|
*/ |
90
|
|
|
public function itCanCreateANewDeeplyNestedEntityInterface(): void |
91
|
|
|
{ |
92
|
|
|
$newObjectFqn = |
93
|
|
|
'EdmondsCommerce\\DoctrineStaticMeta\\Entity\\Interfaces\\Super\\Deeply\\Nested\\TestEntityInterface'; |
94
|
|
|
$file = $this->getCreator()->createTargetFileObject($newObjectFqn)->getTargetFile(); |
95
|
|
|
$expected = self::NESTED_INTERFACE; |
96
|
|
|
$actual = $file->getContents(); |
97
|
|
|
self::assertSame($expected, $actual); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @test |
102
|
|
|
*/ |
103
|
|
|
public function itCanCreateANewDeeplyNestedEntityInterfaceFromEntityFqn(): void |
104
|
|
|
{ |
105
|
|
|
$entityFqn = 'EdmondsCommerce\\DoctrineStaticMeta\\Entities\\Super\\Deeply\\Nested\\TestEntity'; |
106
|
|
|
$file = $this->getCreator() |
107
|
|
|
->setNewObjectFqnFromEntityFqn($entityFqn) |
108
|
|
|
->createTargetFileObject() |
109
|
|
|
->getTargetFile(); |
110
|
|
|
$expected = self::NESTED_INTERFACE; |
111
|
|
|
$actual = $file->getContents(); |
112
|
|
|
self::assertSame($expected, $actual); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths