1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small\CodeGeneration\Creation\Src\Entity\Embeddable\Interfaces\Objects; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Embeddable\Interfaces\Objects\EmbeddableInterfaceCreator; |
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FileFactory; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Factory\FindReplaceFactory; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\File\Writer; |
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper; |
10
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Config; |
11
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Small\ConfigTest; |
12
|
|
|
use PHPUnit\Framework\TestCase; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @small |
16
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Embeddable\Interfaces\Objects\EmbeddableInterfaceCreator |
17
|
|
|
*/ |
18
|
|
|
class EmbeddableInterfaceCreatorTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
private const EXPECTED_FILE = "<?php declare(strict_types=1); |
21
|
|
|
|
22
|
|
|
namespace Test\Project\Entity\Embeddable\Interfaces\Objects\Foo; |
23
|
|
|
|
24
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\AbstractEmbeddableObjectInterface; |
25
|
|
|
|
26
|
|
|
interface BarEmbeddableInterface extends AbstractEmbeddableObjectInterface |
27
|
|
|
{ |
28
|
|
|
public const EMBEDDED_PROP_PROPERTY_ONE = 'propertyOne'; |
29
|
|
|
public const EMBEDDED_PROP_PROPERTY_TWO = 'propertyTwo'; |
30
|
|
|
|
31
|
|
|
public const DEFAULT_PROPERTY_ONE = 'NOT SET'; |
32
|
|
|
public const DEFAULT_PROPERTY_TWO = 'NOT SET'; |
33
|
|
|
|
34
|
|
|
public const DEFAULTS = [ |
35
|
|
|
self::EMBEDDED_PROP_PROPERTY_ONE => self::DEFAULT_PROPERTY_ONE, |
36
|
|
|
self::EMBEDDED_PROP_PROPERTY_TWO => self::DEFAULT_PROPERTY_TWO, |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public function getPropertyOne(): string; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
|
|
public function getPropertyTwo(): string; |
48
|
|
|
}"; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @test |
52
|
|
|
*/ |
53
|
|
|
public function itCanCreateTheFile(): void |
54
|
|
|
{ |
55
|
|
|
$file = $this->getCreator() |
56
|
|
|
->setCatName('Foo') |
57
|
|
|
->setName('Bar') |
58
|
|
|
->createTargetFileObject() |
59
|
|
|
->getTargetFile(); |
60
|
|
|
$expected = self::EXPECTED_FILE; |
61
|
|
|
$actual = $file->getContents(); |
62
|
|
|
self::assertSame($expected, $actual); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function getCreator(): EmbeddableInterfaceCreator |
66
|
|
|
{ |
67
|
|
|
$namespaceHelper = new NamespaceHelper(); |
68
|
|
|
$config = new Config(ConfigTest::SERVER); |
69
|
|
|
|
70
|
|
|
$creator = new EmbeddableInterfaceCreator( |
71
|
|
|
new FileFactory($namespaceHelper, $config), |
72
|
|
|
$namespaceHelper, |
73
|
|
|
new Writer(), |
74
|
|
|
$config, |
75
|
|
|
new FindReplaceFactory() |
76
|
|
|
); |
77
|
|
|
$creator->setProjectRootNamespace('Test\Project'); |
78
|
|
|
|
79
|
|
|
return $creator; |
80
|
|
|
} |
81
|
|
|
} |