1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small\CodeGeneration\Creation\Src\Entity\Embeddable\Interfaces; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\Embeddable\Interfaces\HasEmbeddableInterfaceCreator; |
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 HasEmbeddableInterfaceCreatorTest extends TestCase |
15
|
|
|
{ |
16
|
|
|
private const EXPECTED_FILE = "<?php declare(strict_types=1); |
17
|
|
|
|
18
|
|
|
namespace Test\Project\Entity\Embeddable\Interfaces\Foo; |
19
|
|
|
|
20
|
|
|
use Test\Project\Entity\Embeddable\Interfaces\Objects\Foo\BarEmbeddableInterface; |
21
|
|
|
|
22
|
|
|
interface HasBarEmbeddableInterface |
23
|
|
|
{ |
24
|
|
|
public const PROP_BAR_EMBEDDABLE = 'barEmbeddable'; |
25
|
|
|
public const COLUMN_PREFIX_BAR = 'bar_'; |
26
|
|
|
|
27
|
|
|
public function getBarEmbeddable(): BarEmbeddableInterface; |
28
|
|
|
}"; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @test |
32
|
|
|
*/ |
33
|
|
|
public function itCanCreateTheFile(): void |
34
|
|
|
{ |
35
|
|
|
$file = $this->getCreator() |
36
|
|
|
->setCatName('Foo') |
37
|
|
|
->setName('Bar') |
38
|
|
|
->createTargetFileObject() |
39
|
|
|
->getTargetFile(); |
40
|
|
|
$expected = self::EXPECTED_FILE; |
41
|
|
|
$actual = $file->getContents(); |
42
|
|
|
self::assertSame($expected, $actual); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
private function getCreator(): HasEmbeddableInterfaceCreator |
46
|
|
|
{ |
47
|
|
|
$namespaceHelper = new NamespaceHelper(); |
48
|
|
|
$config = new Config(ConfigTest::SERVER); |
49
|
|
|
|
50
|
|
|
$creator = new HasEmbeddableInterfaceCreator( |
51
|
|
|
new FileFactory($namespaceHelper, $config), |
52
|
|
|
$namespaceHelper, |
53
|
|
|
new Writer(), |
54
|
|
|
$config, |
55
|
|
|
new FindReplaceFactory() |
56
|
|
|
); |
57
|
|
|
$creator->setProjectRootNamespace('Test\Project'); |
58
|
|
|
|
59
|
|
|
return $creator; |
60
|
|
|
} |
61
|
|
|
} |