From 8cec81060f8f44a12df969589401aff25a5d8cfc Mon Sep 17 00:00:00 2001 From: Jakub Pastuszek Date: Tue, 6 Feb 2024 08:37:40 +0100 Subject: [PATCH] Add Backed Enum without name/value specification to test --- tests/Fixtures/ObjectWithEnums.php | 7 +++++++ tests/Serializer/JsonSerializationTest.php | 2 +- tests/Serializer/xml/object_with_enums.xml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/Fixtures/ObjectWithEnums.php b/tests/Fixtures/ObjectWithEnums.php index f7761f086..7789eda7f 100644 --- a/tests/Fixtures/ObjectWithEnums.php +++ b/tests/Fixtures/ObjectWithEnums.php @@ -15,9 +15,15 @@ class ObjectWithEnums * @Serializer\Type("enum<'JMS\Serializer\Tests\Fixtures\Enum\Suit', 'name'>") */ public Suit $ordinary; + /** * @Serializer\Type("enum<'JMS\Serializer\Tests\Fixtures\Enum\BackedSuit', 'value'>") */ + public BackedSuit $backedValue; + + /** + * @Serializer\Type("enum<'JMS\Serializer\Tests\Fixtures\Enum\BackedSuit'>") + */ public BackedSuit $backed; /** @@ -46,6 +52,7 @@ public function __construct() { $this->ordinary = Suit::Clubs; + $this->backedValue = BackedSuit::Clubs; $this->backed = BackedSuit::Clubs; $this->backedArray = [BackedSuit::Clubs, BackedSuit::Hearts]; diff --git a/tests/Serializer/JsonSerializationTest.php b/tests/Serializer/JsonSerializationTest.php index 0c6800e89..e72b45411 100644 --- a/tests/Serializer/JsonSerializationTest.php +++ b/tests/Serializer/JsonSerializationTest.php @@ -141,7 +141,7 @@ protected static function getContent($key) $outputs['custom_datetimeinterface'] = '{"custom":"2021-09-07"}'; $outputs['data_integer'] = '{"data":10000}'; $outputs['uid'] = '"66b3177c-e03b-4a22-9dee-ddd7d37a04d5"'; - $outputs['object_with_enums'] = '{"ordinary":"Clubs","backed":"C","ordinary_array":["Clubs","Spades"],"backed_array":["C","H"],"ordinary_auto_detect":"Clubs","backed_auto_detect":"C","backed_int_auto_detect":3,"backed_int":3,"backed_name":"C","backed_int_forced_str":3}'; + $outputs['object_with_enums'] = '{"ordinary":"Clubs","backedValue":"C","backed":"C","ordinary_array":["Clubs","Spades"],"backed_array":["C","H"],"ordinary_auto_detect":"Clubs","backed_auto_detect":"C","backed_int_auto_detect":3,"backed_int":3,"backed_name":"C","backed_int_forced_str":3}'; $outputs['object_with_autodetect_enums'] = '{"ordinary_array_auto_detect":["Clubs","Spades"],"backed_array_auto_detect":["C","H"],"mixed_array_auto_detect":["Clubs","H"]}'; $outputs['object_with_enums_disabled'] = '{"ordinary_array_auto_detect":[{"name":"Clubs"},{"name":"Spades"}],"backed_array_auto_detect":[{"name":"Clubs","value":"C"},{"name":"Hearts","value":"H"}],"mixed_array_auto_detect":[{"name":"Clubs"},{"name":"Hearts","value":"H"}]}'; } diff --git a/tests/Serializer/xml/object_with_enums.xml b/tests/Serializer/xml/object_with_enums.xml index bba1a2b00..0a19b9e14 100644 --- a/tests/Serializer/xml/object_with_enums.xml +++ b/tests/Serializer/xml/object_with_enums.xml @@ -1,6 +1,7 @@ +