diff --git a/src/classes/Plan.php b/src/classes/Plan.php index 658c50b..0faf3a9 100644 --- a/src/classes/Plan.php +++ b/src/classes/Plan.php @@ -146,6 +146,11 @@ public function items(): Collection throw new InvalidArgumentException('Invalid item ' . $num); } + // skip dummy items (e.g. radiator from the room designer) + if (is_string($item['id'] ?? null) !== true) { + continue; + } + $items[] = new Configuration($item); } diff --git a/tests/Roomle/ConfigurationTest.php b/tests/Roomle/ConfigurationTest.php index 5b2b4d7..d5b7075 100644 --- a/tests/Roomle/ConfigurationTest.php +++ b/tests/Roomle/ConfigurationTest.php @@ -15,7 +15,7 @@ public function setUp(): void new App([ 'request' => [ 'body' => [ - 'roomle-configuration' => '{"id": null, "items": [{"depth": 123}]}' + 'roomle-configuration' => '{"id": null, "items": [{"id": "some-id", "depth": 123}]}' ] ], 'urls' => [ @@ -56,11 +56,13 @@ public function testConfiguratorUrl_Invalid() public function testConstruct_Array() { $configuration = new Configuration([ + 'id' => 'some-id', 'depth' => 1337 ]); $this->assertSame(1337, $configuration->depth()); $configuration = Configuration::lazyInstance([ + 'id' => 'some-id', 'depth' => 1337 ]); $this->assertSame(1337, $configuration->depth()); @@ -91,7 +93,7 @@ public function testConstruct_RequestInvalid() */ public function testConstruct_String() { - $configuration = Configuration::lazyInstance('{"items": [{"depth": 1337}]}'); + $configuration = Configuration::lazyInstance('{"items": [{"id": "some-id", "depth": 1337}]}'); $this->assertSame(1337, $configuration->depth()); } diff --git a/tests/Roomle/PlanTest.php b/tests/Roomle/PlanTest.php index b4ba0ef..c449a0a 100644 --- a/tests/Roomle/PlanTest.php +++ b/tests/Roomle/PlanTest.php @@ -142,6 +142,10 @@ public function testGroupedItems() [ 'id' => 'some:item1', 'depth' => 123 + ], + [ + 'id' => null, + 'label' => 'Radiator' ] ] ]); @@ -207,6 +211,10 @@ public function testItems() [ 'id' => 'some:item1', 'depth' => 123 + ], + [ + 'id' => null, + 'label' => 'Radiator' ] ] ]);