1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Medium\Entity\Testing; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\AbstractIntegrationTest; |
|
|
|
|
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityDebugDumper; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest; |
9
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class EntityDebugDumperTest |
13
|
|
|
* |
14
|
|
|
* @package EdmondsCommerce\DoctrineStaticMeta\Entity\Testing |
15
|
|
|
* @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\EntityDebugDumper |
16
|
|
|
* @medium |
17
|
|
|
*/ |
18
|
|
|
class EntityDebugDumperTest extends AbstractTest |
19
|
|
|
{ |
20
|
|
|
public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_MEDIUM . '/EntityDebugDumperTest'; |
21
|
|
|
|
22
|
|
|
private const TEST_ENTITY_FQN = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_PERSON; |
23
|
|
|
|
24
|
|
|
private const VALUE_DECIMAL = '20.10000000000000'; |
25
|
|
|
protected static $buildOnce = true; |
26
|
|
|
/** |
27
|
|
|
* @var EntityDebugDumper |
28
|
|
|
*/ |
29
|
|
|
private static $dumper; |
30
|
|
|
|
31
|
|
|
public function setup() |
32
|
|
|
{ |
33
|
|
|
parent::setUp(); |
34
|
|
|
if (false === self::$built) { |
35
|
|
|
$this->getTestCodeGenerator() |
36
|
|
|
->copyTo(self::WORK_DIR); |
37
|
|
|
self::$built = true; |
38
|
|
|
} |
39
|
|
|
$this->setupCopiedWorkDir(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public static function setUpBeforeClass() |
43
|
|
|
{ |
44
|
|
|
parent::setUpBeforeClass(); |
45
|
|
|
self::$dumper = new EntityDebugDumper(); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @test |
50
|
|
|
*/ |
51
|
|
|
public function itRemovesTrailingZerosOnDecimals(): string |
52
|
|
|
{ |
53
|
|
|
$dump = self::$dumper->dump($this->getEntity()); |
54
|
|
|
self::assertNotContains(self::VALUE_DECIMAL, $dump); |
55
|
|
|
|
56
|
|
|
return $dump; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private function getEntity(): EntityInterface |
60
|
|
|
{ |
61
|
|
|
$emailAddressDto = $this->getEntityDtoFactory() |
62
|
|
|
->createEmptyDtoFromEntityFqn( |
63
|
|
|
$this->getCopiedFqn( |
64
|
|
|
self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_EMAIL |
65
|
|
|
) |
66
|
|
|
)->setEmailAddress('[email protected]'); |
67
|
|
|
|
68
|
|
|
$personDto = $this->getEntityDtoFactory() |
69
|
|
|
->createEmptyDtoFromEntityFqn($this->getCopiedFqn(self::TEST_ENTITY_FQN)) |
70
|
|
|
->setDecimal(self::VALUE_DECIMAL); |
71
|
|
|
$personDto->getAttributesEmails()->add($emailAddressDto); |
72
|
|
|
$this->getDataFillerFactory() |
73
|
|
|
->getInstanceFromEntityFqn($this->getCopiedFqn(self::TEST_ENTITY_FQN)) |
74
|
|
|
->updateDtoWithFakeData($personDto); |
75
|
|
|
|
76
|
|
|
$entity = $this->createEntity( |
77
|
|
|
$this->getCopiedFqn(self::TEST_ENTITY_FQN), |
78
|
|
|
$personDto |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
return $entity; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @test |
86
|
|
|
* @depends itRemovesTrailingZerosOnDecimals |
87
|
|
|
*/ |
88
|
|
|
public function itConvertsCollectionsToAListOfIDs(string $dump): void |
89
|
|
|
{ |
90
|
|
|
self::assertStringContainsString( |
91
|
|
|
'[getAttributesEmails] => Array |
92
|
|
|
( |
93
|
|
|
[0] => EntityDebugDumperTest_ItRemovesTrailingZerosOnDecimals_\Entities\Attributes\Email:', |
94
|
|
|
$dump |
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths