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