Skip to content

Commit

Permalink
Use item grouping in the email snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Jul 30, 2023
1 parent fe5d819 commit 7fd7728
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/config/snippets/roomle/configuration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php /** @var LukasBestle\Roomle\Configuration $configuration */ ?>
<?php if ($configuration->count()): ?><?= $configuration->count() ?>x <?php endif ?>
<?= $configuration->label() ?> (<?= $configuration->id() ?>)
<?= $configuration->size() . "\n" ?>
<?= $configuration->configuratorUrl() . "\n" ?>
Expand Down
2 changes: 1 addition & 1 deletion src/config/snippets/roomle/plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<?= $plan->label() ?> (<?= $plan->id() ?>)
<?= $plan->configuratorUrl() . "\n" ?>

<?php foreach ($plan->items() as $item): ?>
<?php foreach ($plan->groupedItems() as $item): ?>
<?= $item . "\n" ?>
<?php endforeach ?>
57 changes: 57 additions & 0 deletions tests/Roomle/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,61 @@ public function testToString()

$this->assertStringEqualsFile(__DIR__ . '/fixtures/configuration.txt', (string)$configuration);
}

/**
* @covers ::__toString
*/
public function testToString_WithCount()
{
$configuration = new Configuration([
'configuratorUrl' => 'https://example.com/configurator',
'count' => 3,
'depth' => 12,
'height' => 34,
'id' => 'some:id',
'label' => 'Some product',
'width' => 56,
'parts' => [
[
'articleNr' => '123.456.789',
'componentId' => 'some:component1',
'count' => 2,
'label' => 'Some part',
'parameters' => [
[
'key' => 'height',
'label' => 'Height',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '123.0'
],
[
'key' => 'width',
'label' => 'Width',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '456.0'
]
]
],
[
'articleNr' => '987.654.321',
'componentId' => 'some:component2',
'count' => 1,
'label' => 'Some other part',
'parameters' => [
[
'key' => 'height',
'label' => 'Height',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '789.0'
]
]
]
],
]);

$this->assertStringEqualsFile(__DIR__ . '/fixtures/configuration_count.txt', (string)$configuration);
}
}
49 changes: 48 additions & 1 deletion tests/Roomle/PlanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,54 @@ public function testToString_Plan()
]
]
]
]
],
[
'configuratorUrl' => 'https://example.com/configurator/item1',
'depth' => 12,
'height' => 34,
'id' => 'some:id1',
'label' => 'Some product',
'width' => 56,
'parts' => [
[
'articleNr' => '123.456.789',
'componentId' => 'some:component1',
'count' => 2,
'label' => 'Some part',
'parameters' => [
[
'key' => 'height',
'label' => 'Height',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '123.0'
],
[
'key' => 'width',
'label' => 'Width',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '456.0'
]
]
],
[
'articleNr' => '987.654.321',
'componentId' => 'some:component2',
'count' => 1,
'label' => 'Some other part',
'parameters' => [
[
'key' => 'height',
'label' => 'Height',
'type' => 'Decimal',
'unitType' => 'length',
'value' => '789.0'
]
]
]
]
],
]
]);

Expand Down
11 changes: 11 additions & 0 deletions tests/Roomle/fixtures/configuration_count.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
3x Some product (some:id)
W 5.6 cm / H 3.4 cm / D 1.2 cm
https://example.com/configurator

2x Some part (123.456.789)
Height: 12.3 cm
Width: 45.6 cm

1x Some other part (987.654.321)
Height: 78.9 cm

4 changes: 2 additions & 2 deletions tests/Roomle/fixtures/plan.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Plan (abcdefghi)
https://example.com/configurator/plan

Some product (some:id1)
2x Some product (some:id1)
W 5.6 cm / H 3.4 cm / D 1.2 cm
https://example.com/configurator/item1

Expand All @@ -13,7 +13,7 @@ Width: 45.6 cm
Height: 78.9 cm


Some other product (some:id2)
1x Some other product (some:id2)
W 5.6 cm / H 3.4 cm / D 1.2 cm
https://example.com/configurator/item2

Expand Down

0 comments on commit 7fd7728

Please sign in to comment.