Skip to content

Commit ea3c3ac

Browse files
committed
Add test for __debugInfo
1 parent 9d35a0c commit ea3c3ac

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/AbstractEntity.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ public function __debugInfo(): array
137137
{
138138
$result = [];
139139
foreach ((new \ReflectionClass($this))->getProperties() as $property) {
140-
if ($property->name === '_initialColumns') {
141-
continue;
142-
}
143140
if (!$property->isInitialized($this)) {
144141
continue;
145142
}

tests/AbstractEntityTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Helpers\DateTimeHelper;
7+
use Composite\Entity\Tests\TestStand\TestSubEntity;
78

89
final class AbstractEntityTest extends \PHPUnit\Framework\TestCase
910
{
@@ -219,4 +220,27 @@ public function __construct(
219220
$loadedEntity = $entity::fromArray($dataArray);
220221
$this->assertEquals($dataArray, $loadedEntity->toArray());
221222
}
223+
224+
public function test_debugInfo(): void
225+
{
226+
$entity = new class extends AbstractEntity {
227+
public int $var1 = 1;
228+
protected int $var2 = 2;
229+
private int $var3 = 3;
230+
public int $var4;
231+
public function __construct(
232+
public TestSubEntity $subEntity = new TestSubEntity(),
233+
) {
234+
}
235+
};
236+
$expected = print_r([
237+
'var1' => 1,
238+
'var2' => 2,
239+
'var3:private' => 3,
240+
'subEntity' => new TestSubEntity(),
241+
], true);
242+
243+
$expected = str_replace('Array', 'Composite\Entity\AbstractEntity@anonymous Object', $expected);
244+
$this->assertEquals($expected, print_r($entity, true));
245+
}
222246
}

0 commit comments

Comments
 (0)