From dddb91a673c3e1263880d32a54df034350617f59 Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Mon, 18 Nov 2024 09:46:27 +0000 Subject: [PATCH] Add end to end tests for False types From `ea7f7be4cb6ca2d1ed5e156b57f1413be8936e82`, but I can't cherry-pick because it's cross-remote --- .../DeserializationGraphNavigator.php | 2 ++ tests/Fixtures/DataFalse.php | 13 +++++++++ tests/Fixtures/DataTrue.php | 10 +++++++ tests/Serializer/JsonSerializationTest.php | 27 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 tests/Fixtures/DataFalse.php create mode 100644 tests/Fixtures/DataTrue.php diff --git a/src/GraphNavigator/DeserializationGraphNavigator.php b/src/GraphNavigator/DeserializationGraphNavigator.php index a29e43c12..edf1e6a68 100644 --- a/src/GraphNavigator/DeserializationGraphNavigator.php +++ b/src/GraphNavigator/DeserializationGraphNavigator.php @@ -128,6 +128,8 @@ public function accept($data, ?array $type = null) case 'bool': case 'boolean': + case 'false': + case 'true': return $this->visitor->visitBoolean($data, $type); case 'double': diff --git a/tests/Fixtures/DataFalse.php b/tests/Fixtures/DataFalse.php new file mode 100644 index 000000000..ce3d2632f --- /dev/null +++ b/tests/Fixtures/DataFalse.php @@ -0,0 +1,13 @@ +markTestSkipped('False type requires PHP 8.2'); + return; + } + + self::assertEquals( + static::getContent('data_false'), + $this->serialize(new DataFalse(false)), + ); + + self::assertEquals( + new DataFalse(false), + $this->deserialize(static::getContent('data_false'), DataFalse::class), + ); + + //What should we expect here? + self::assertEquals( + null, + $this->deserialize(static::getContent('data_true'), DataFalse::class), + ); + } + public function testDeserializingComplexDiscriminatedUnionProperties() { if (PHP_VERSION_ID < 80000) {