diff --git a/src/Component/Data/Faker.php b/src/Component/Data/Faker.php index 482198a..2d2f517 100644 --- a/src/Component/Data/Faker.php +++ b/src/Component/Data/Faker.php @@ -46,7 +46,7 @@ private function createFakeData(array $params, mixed $variation): array if (!\array_key_exists($name, $result)) { // set from variation - $result[$name] = $variation; + $result[$name] = $variation[$name] ?? $variation; } } diff --git a/src/Component/Data/Generator/NullGenerator.php b/src/Component/Data/Generator/NullGenerator.php index a723709..8c9687f 100644 --- a/src/Component/Data/Generator/NullGenerator.php +++ b/src/Component/Data/Generator/NullGenerator.php @@ -10,7 +10,7 @@ class NullGenerator implements GeneratorInterface { public function supports(string $type, mixed $context = null): bool { - return empty($context); + return null === $context || '' === $context; } public function generate(string $type, mixed $context = null): null diff --git a/tests/Functional/Service/ComponentItemFactoryTest.php b/tests/Functional/Service/ComponentItemFactoryTest.php index 1cb145c..5fd9834 100644 --- a/tests/Functional/Service/ComponentItemFactoryTest.php +++ b/tests/Functional/Service/ComponentItemFactoryTest.php @@ -261,6 +261,7 @@ public function testCreateForArrayParameter(): void 'variation1' => [ 'arrayParam' => [ 'param1' => 'Some cool hipster text', + 'param2' => false, ], ], ], @@ -275,7 +276,7 @@ public function testCreateForArrayParameter(): void self::assertIsArray($variations); self::assertArrayHasKey('variation1', $variations); self::assertEquals('Some cool hipster text', $variations['variation1']['arrayParam']['param1']); - self::assertIsBool($variations['variation1']['arrayParam']['param2']); + self::assertFalse($variations['variation1']['arrayParam']['param2']); } public static function getInvalidComponentConfigurationTestCases(): iterable