Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/Support/Throws/allowed-throws.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
'test' => ObjectPropertyPresenceTest::class.'::optional_property_preserves_absence_null_and_value#lazy object whose initializer throws',
'throw' => RuntimeException::class,
'via' => 'src/Encoder/ObjectEncoder.php -> VeeWee\\Reflecta\\Lens\\Lens->get',
'throws' => 4,
'throws' => 3,
'reason' => 'The fixture is a lazy object whose initializer throws on every access the encoder lenses make to it, to prove that the encoder keeps writing xsi:nil for it.',
],
[
'test' => ObjectPropertyPresenceTest::class.'::optional_property_preserves_absence_null_and_value#lazy object whose initializer throws',
'throw' => RuntimeException::class,
'via' => 'src/Encoder/ObjectEncoder.php -> VeeWee\\Reflecta\\Reflect\\property_is_initialized',
'throws' => 1,
'reason' => 'The same lazy object throws again when the encoder checks whether the null note is absent, and property_is_initialized() counts it as present.',
],
];
6 changes: 5 additions & 1 deletion tests/Unit/Encoder/ObjectPropertyPresenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ private static function failingLazyObject(): object
public ?string $note = null;
};

$thrown = [];

return (new ReflectionClass($class))->newLazyGhost(
static fn (): never => throw new RuntimeException('The initializer fails.')
static function () use (&$thrown): never {
throw $thrown[] = new RuntimeException('The initializer fails.');
}
);
}

Expand Down