From 9c7cc05901cc6e726c38cb8953bf38733d1f6c7e Mon Sep 17 00:00:00 2001 From: Jonas De Gauquier Date: Fri, 6 Dec 2024 11:25:17 +0100 Subject: [PATCH] Fixed Call to a member function getValues() on array --- src/Component/Configurator/Configuration.php | 4 +--- src/Component/Configurator/ReadOnlyConfiguration.php | 4 +++- tests/Component/Configurator/ConfigurationTest.php | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Component/Configurator/Configuration.php b/src/Component/Configurator/Configuration.php index 9e03197e..3450772a 100644 --- a/src/Component/Configurator/Configuration.php +++ b/src/Component/Configurator/Configuration.php @@ -220,9 +220,7 @@ public function updateList(string $listName, array $list): void public function getLists(): array { - return array_map(function ($list) { - return $list->getValues(); - }, $this->lists); + return $this->lists; } public function getList(string $alias): ?array diff --git a/src/Component/Configurator/ReadOnlyConfiguration.php b/src/Component/Configurator/ReadOnlyConfiguration.php index 5c7083a7..9ef74977 100644 --- a/src/Component/Configurator/ReadOnlyConfiguration.php +++ b/src/Component/Configurator/ReadOnlyConfiguration.php @@ -44,7 +44,9 @@ public function getSources(): SourceCollection public function getLists(): array { - return $this->lists; + return array_map(function ($list) { + return $list->getValues(); + }, $this->lists); } public function getList(string $alias) diff --git a/tests/Component/Configurator/ConfigurationTest.php b/tests/Component/Configurator/ConfigurationTest.php index 178d5005..6e01aac7 100644 --- a/tests/Component/Configurator/ConfigurationTest.php +++ b/tests/Component/Configurator/ConfigurationTest.php @@ -2,6 +2,7 @@ namespace Tests\Misery\Component\Configurator; +use Misery\Component\Common\Collection\ArrayCollection; use PHPUnit\Framework\TestCase; use Misery\Component\Configurator\Configuration; use Misery\Component\Common\Client\ApiClientInterface; @@ -175,8 +176,10 @@ public function testAddAndGetLists() $this->assertArrayHasKey('list1', $lists); $this->assertArrayHasKey('list2', $lists); - $this->assertEquals($list1, $lists['list1']); - $this->assertEquals($list2, $lists['list2']); + $collection1 = new ArrayCollection($list1); + $collection2 = new ArrayCollection($list2); + $this->assertEquals($collection1, $lists['list1']); + $this->assertEquals($collection2, $lists['list2']); // Updating a list $updatedList = ['itemX', 'itemY', 'itemZ']; @@ -184,7 +187,8 @@ public function testAddAndGetLists() $updatedLists = $configuration->getLists(); - $this->assertEquals($updatedList, $updatedLists['list1']); + $updatedCollectionList = new ArrayCollection($updatedList); + $this->assertEquals($updatedCollectionList, $updatedLists['list1']); // Retrieving a single list $retrievedList = $configuration->getList('list1');