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