Skip to content

Commit

Permalink
Skip dummy items
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Mar 25, 2024
1 parent 7af73f1 commit b4e3d8e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/classes/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Roomle/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Roomle/PlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ public function testGroupedItems()
[
'id' => 'some:item1',
'depth' => 123
],
[
'id' => null,
'label' => 'Radiator'
]
]
]);
Expand Down Expand Up @@ -207,6 +211,10 @@ public function testItems()
[
'id' => 'some:item1',
'depth' => 123
],
[
'id' => null,
'label' => 'Radiator'
]
]
]);
Expand Down

0 comments on commit b4e3d8e

Please sign in to comment.