|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small\CodeGeneration\Creation\Tests\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Tests\Entities\AbstractEntityTestCreator; |
|
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
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Tests\Entities\AbstractEntityTestCreator |
|
16
|
|
|
* @small |
|
17
|
|
|
*/ |
|
18
|
|
|
class AbstractEntityTestCreatorTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @test |
|
22
|
|
|
*/ |
|
23
|
|
|
public function itCanCreateTheAbstractEntityTest() |
|
24
|
|
|
{ |
|
25
|
|
|
$file = $this->getCreator()->createTargetFileObject()->getTargetFile(); |
|
26
|
|
|
$expected = '<?php declare(strict_types=1); |
|
27
|
|
|
/** |
|
28
|
|
|
* To avoid collisions we use the verbose FQN for everything |
|
29
|
|
|
* This inevitably creates excessively long lines |
|
30
|
|
|
* So we disable that sniff in this file |
|
31
|
|
|
*/ |
|
32
|
|
|
//phpcs:disable Generic.Files.LineLength.TooLong |
|
33
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Entities; |
|
34
|
|
|
|
|
35
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity as DSM; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Class AbstractEntityTest |
|
39
|
|
|
* |
|
40
|
|
|
* This abstract test is designed to give you a good level of test coverage for your entities without any work required. |
|
41
|
|
|
* |
|
42
|
|
|
* You should extend the test with methods that test your specific business logic, your validators and anything else. |
|
43
|
|
|
* |
|
44
|
|
|
* You can override the methods, properties and constants as you see fit. |
|
45
|
|
|
* |
|
46
|
|
|
* @package EdmondsCommerce\DoctrineStaticMeta\Entity |
|
47
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
|
48
|
|
|
* @SuppressWarnings(PHPMD.NumberOfChildren) |
|
49
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
|
50
|
|
|
*/ |
|
51
|
|
|
abstract class AbstractEntityTest extends DSM\Testing\AbstractEntityTest |
|
52
|
|
|
{ |
|
53
|
|
|
} |
|
54
|
|
|
'; |
|
55
|
|
|
$actual = $file->getContents(); |
|
56
|
|
|
self::assertSame($expected, $actual); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
private function getCreator(): AbstractEntityTestCreator |
|
60
|
|
|
{ |
|
61
|
|
|
$namespaceHelper = new NamespaceHelper(); |
|
62
|
|
|
$config = new Config(ConfigTest::SERVER); |
|
63
|
|
|
|
|
64
|
|
|
return new AbstractEntityTestCreator( |
|
65
|
|
|
new FileFactory($namespaceHelper, $config), |
|
66
|
|
|
$namespaceHelper, |
|
67
|
|
|
new Writer(), |
|
68
|
|
|
$config, |
|
69
|
|
|
new FindReplaceFactory() |
|
70
|
|
|
); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|