Skip to content

Commit

Permalink
pr suggestions around test validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslkingsley committed Jun 13, 2024
1 parent c879460 commit 8814486
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions tests/ArrayBasedFormatterTestCases.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,14 @@ public function value_objects_with_similar_property_names_work_validate(mixed $s
self::assertSame('me@example.com', $toTest['email']);
}

public function nullable_value_objects_flattened_validate(mixed $serialized): void
{
$toTest = $this->arrayify($serialized);

self::assertTrue(isset($toTest['order_id']));
self::assertNull($toTest['order_id']);
}

public function multiple_same_class_value_objects_work_validate(mixed $serialized): void
{
$toTest = $this->arrayify($serialized);
Expand Down
14 changes: 7 additions & 7 deletions tests/SerdeTestCases.php
Original file line number Diff line number Diff line change
Expand Up @@ -1630,21 +1630,21 @@ public function nullable_value_objects_flattened(): void

$data = new FlattenedValueObjectMain(null);

// Serialisation here hides the issue...
// $serialized = $s->serialize($data, $this->format);
$serialized = $s->serialize($data, $this->format);

$serialized = match ($this->format) {
'array' => ['order_id' => null],
'json' => '{"order_id":null}',
'yaml' => 'order_id: null',
};
$this->nullable_value_objects_flattened_validate($serialized);

/** @var FlattenedNullableMain $result */
$result = $s->deserialize($serialized, from: $this->format, to: $data::class);

self::assertEquals($data, $result);
}

public function nullable_value_objects_flattened_validate(mixed $serialized): void
{

}

#[Test]
public function non_sequence_arrays_are_normalized_to_sequences(): void
{
Expand Down

0 comments on commit 8814486

Please sign in to comment.