mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
DX: [docgen] add more test for docgenObjectNormalizer and AccompanyingPeriodResourceNormalizer
This commit is contained in:
@@ -77,6 +77,19 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertArrayNotHasKey('baz', $actual['child']);
|
||||
}
|
||||
|
||||
public function testNormalizableBooleanPropertyOrMethodOnNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]);
|
||||
|
||||
$expected = [
|
||||
'foo' => null,
|
||||
'thing' => null,
|
||||
'isNull' => true,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizationBasic()
|
||||
{
|
||||
$scope = new Scope();
|
||||
@@ -93,6 +106,22 @@ final class DocGenObjectNormalizerTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $normalized, 'test normalization fo a scope');
|
||||
}
|
||||
|
||||
public function testNormalizeBooleanPropertyOrMethod()
|
||||
{
|
||||
$testable = new TestableClassWithBool();
|
||||
$testable->foo = false;
|
||||
|
||||
$actual = $this->normalizer->normalize($testable, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => TestableClassWithBool::class]);
|
||||
|
||||
$expected = [
|
||||
'foo' => false,
|
||||
'thing' => true,
|
||||
'isNull' => false,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function testNormalizeNull()
|
||||
{
|
||||
$actual = $this->normalizer->normalize(null, 'docgen', [AbstractNormalizer::GROUPS => ['docgen:read'], 'docgen:expects' => Scope::class]);
|
||||
@@ -170,3 +199,19 @@ class TestableChildClass
|
||||
*/
|
||||
public string $foo = 'bar';
|
||||
}
|
||||
|
||||
class TestableClassWithBool
|
||||
{
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
*/
|
||||
public bool $foo;
|
||||
|
||||
/**
|
||||
* @Serializer\Groups("docgen:read")
|
||||
*/
|
||||
public function getThing(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user