From ff9824a6da6cfa737d510d466a9a09e57ca5b358 Mon Sep 17 00:00:00 2001 From: Keith Brink Date: Thu, 14 Nov 2024 10:20:23 +0300 Subject: [PATCH] Improve test coverage --- src/Data/Base/TypedCollection.php | 2 -- tests/Unit/Data/Base/TypedCollectionTest.php | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Data/Base/TypedCollection.php b/src/Data/Base/TypedCollection.php index 9c4bcbc..423669c 100644 --- a/src/Data/Base/TypedCollection.php +++ b/src/Data/Base/TypedCollection.php @@ -61,8 +61,6 @@ public function toArrayObject( ): \ArrayObject { return new \ArrayObject($this->map(function ($item) use ($case) { return match (true) { - $item instanceof TypedCollection => $item->toArrayObject(case: $case), - $item instanceof Collection => $item->toArrayObject(), $item instanceof Data => $item->toArrayObject(case: $case), $item instanceof BackedEnum => $item->value, default => $item, diff --git a/tests/Unit/Data/Base/TypedCollectionTest.php b/tests/Unit/Data/Base/TypedCollectionTest.php index 32d3005..93093d5 100644 --- a/tests/Unit/Data/Base/TypedCollectionTest.php +++ b/tests/Unit/Data/Base/TypedCollectionTest.php @@ -3,6 +3,8 @@ namespace Jasara\AmznSPA\Tests\Unit\Data\Base; use Jasara\AmznSPA\Data\Base\TypedCollection; +use Jasara\AmznSPA\Data\Schemas\FulfillmentInbound\v20240320\PrepType; +use Jasara\AmznSPA\Data\Schemas\FulfillmentInbound\v20240320\PrepTypeList; use Jasara\AmznSPA\Data\Schemas\Tokens\RestrictedResourceSchema; use Jasara\AmznSPA\Data\Schemas\Tokens\RestrictedResourcesListSchema; use Jasara\AmznSPA\Tests\Unit\UnitTestCase; @@ -110,5 +112,10 @@ public function testToArrayObject(): void $this->assertEquals('GET', $array_object[0]['method']); $this->assertEquals('/path', $array_object[0]['path']); + + $enum = PrepType::Sharp; + $collection = new PrepTypeList([$enum]); + $array_object = $collection->toArrayObject(); + $this->assertEquals($enum->value, $array_object[0]); } }