diff --git a/src/Charts/ChartObjectInfo.php b/src/Charts/ChartObjectInfo.php index a042aae..485ac7e 100644 --- a/src/Charts/ChartObjectInfo.php +++ b/src/Charts/ChartObjectInfo.php @@ -76,4 +76,8 @@ class ChartObjectInfo * @var string */ public $zone; + /** + * @var \Seatsio\Common\Floor + */ + var $floor; } diff --git a/tests/Reports/Charts/ChartReportsTest.php b/tests/Reports/Charts/ChartReportsTest.php index ee9f402..4608823 100644 --- a/tests/Reports/Charts/ChartReportsTest.php +++ b/tests/Reports/Charts/ChartReportsTest.php @@ -2,6 +2,7 @@ namespace Reports\Charts; +use Seatsio\Common\Floor; use Seatsio\Common\IDs; use Seatsio\Reports\Charts\ChartReports; use Seatsio\SeatsioClient; @@ -94,6 +95,7 @@ public function testReportItemProperties($updateChart, $getReport) self::assertNotNull($reportItem->isAccessible); self::assertNotNull($reportItem->isCompanionSeat); self::assertNotNull($reportItem->hasRestrictedView); + self::assertNull($reportItem->floor); } /** @@ -141,6 +143,23 @@ public function testByLabel($updateChart, $getReport) self::assertCount(1, $report["A-2"]); } + /** + * @dataProvider byLabelDataProvider + */ + public function testByLabelWithFloor($updateChart, $getReport) + { + $chartKey = $this->createTestChartWithFloors(); + $updateChart($this->seatsioClient, $chartKey); + + $report = $getReport($this->seatsioClient, $chartKey); + + $floors = self::floors(); + self::assertEquals($floors[0], $report["S1-A-1"][0]->floor); + self::assertEquals($floors[0], $report["S1-A-2"][0]->floor); + self::assertEquals($floors[1], $report["S2-B-1"][0]->floor); + self::assertEquals($floors[1], $report["S2-B-2"][0]->floor); + } + /** * @dataProvider byObjectTypeDataProvider */ @@ -155,6 +174,23 @@ public function testByObjectType($updateChart, $getReport) self::assertCount(2, $report["generalAdmission"]); } + /** + * @dataProvider byObjectTypeDataProvider + */ + public function testByObjectTypeWithFloors($updateChart, $getReport) + { + $chartKey = $this->createTestChartWithFloors(); + $updateChart($this->seatsioClient, $chartKey); + + $report = $getReport($this->seatsioClient, $chartKey); + + $floors = self::floors(); + self::assertEquals($floors[0], $report["seat"][0]->floor); + self::assertEquals($floors[0], $report["seat"][1]->floor); + self::assertEquals($floors[1], $report["seat"][2]->floor); + self::assertEquals($floors[1], $report["seat"][3]->floor); + } + public static function byObjectTypeDataProvider(): array { $getReport = function(SeatsioClient $client, string $chartKey) @@ -237,6 +273,23 @@ public function testByCategoryKey($updateChart, $getReport) self::assertCount(17, $report["10"]); } + /** + * @dataProvider byCategoryKeyDataProvider + */ + public function testByCategoryKeyWithFloor($updateChart, $getReport) + { + $chartKey = $this->createTestChartWithFloors(); + $updateChart($this->seatsioClient, $chartKey); + + $report = $this->seatsioClient->chartReports->byCategoryKey($chartKey); + + $floors = self::floors(); + self::assertEquals($floors[0], $report["1"][0]->floor); + self::assertEquals($floors[0], $report["1"][1]->floor); + self::assertEquals($floors[1], $report["2"][0]->floor); + self::assertEquals($floors[1], $report["2"][1]->floor); + } + public static function byCategoryKeyDataProvider(): array { $getReport = function(SeatsioClient $client, string $chartKey) { @@ -267,6 +320,23 @@ public function testByCategoryLabel($updateChart, $getReport) self::assertCount(17, $report["Cat2"]); } + /** + * @dataProvider byCategoryLabelDataProvider + */ + public function testByCategoryLabelWithFloors($updateChart, $getReport) + { + $chartKey = $this->createTestChartWithFloors(); + $updateChart($this->seatsioClient, $chartKey); + + $report = $this->seatsioClient->chartReports->byCategoryLabel($chartKey); + + $floors = self::floors(); + self::assertEquals($floors[0], $report["CatA"][0]->floor); + self::assertEquals($floors[0], $report["CatA"][1]->floor); + self::assertEquals($floors[1], $report["CatB"][0]->floor); + self::assertEquals($floors[1], $report["CatB"][1]->floor); + } + public static function byCategoryLabelDataProvider(): array { $getReport = function(SeatsioClient $client, string $chartKey) { @@ -297,6 +367,23 @@ public function testBySection($updateChart, $getReport) self::assertCount(35, $report["Section B"]); } + /** + * @dataProvider bySectionDataProvider + */ + public function testBySectionWithFloors($updateChart, $getReport) + { + $chartKey = $this->createTestChartWithFloors(); + $updateChart($this->seatsioClient, $chartKey); + + $report = $getReport($this->seatsioClient, $chartKey); + + $floors = self::floors(); + self::assertEquals($floors[0], $report["S1"][0]->floor); + self::assertEquals($floors[0], $report["S1"][1]->floor); + self::assertEquals($floors[1], $report["S2"][0]->floor); + self::assertEquals($floors[1], $report["S2"][1]->floor); + } + public static function bySectionDataProvider(): array { $getReport = function(SeatsioClient $client, string $chartKey) { @@ -343,4 +430,17 @@ public static function byZoneDataProvider(): array array(ChartReportsTest::createDraftReport(), $getDraftReport) ); } + + private static function floors(): array + { + $floor1 = new Floor(); + $floor1->name = "1"; + $floor1->displayName = "Floor 1"; + + $floor2 = new Floor(); + $floor2->name = "2"; + $floor2->displayName = "Floor 2"; + + return [$floor1, $floor2]; + } } diff --git a/tests/sampleChartWithFloors.json b/tests/sampleChartWithFloors.json index e4679c1..9817137 100644 --- a/tests/sampleChartWithFloors.json +++ b/tests/sampleChartWithFloors.json @@ -1,7 +1,7 @@ { - "name": "chartWithFloors", + "name": "Multi-floor test", "tablesLabelCounter": 1, - "uuidCounter": 43, + "uuidCounter": 13, "categories": { "list": [ { @@ -12,12 +12,12 @@ }, { "label": "CatB", - "color": "#CD254A", + "color": "#662C4E", "accessible": false, "key": 2 } ], - "maxCategoryKey": 2 + "maxCategoryKey": 1 }, "zones": { "list": [] @@ -25,14 +25,14 @@ "rowSpacing": 14, "rowChairSpacing": 5, "colorScheme": "light", - "version": 21, + "version": 22, "venueType": "WITH_SECTIONS_AND_FLOORS", "sectionScaleFactor": 100, "referenceChartVisible": true, "subChartFloors": [ { - "height": 173.11, - "width": 268.67, + "height": 63.11, + "width": 1294.22, "tables": [], "texts": [], "imageObjects": [], @@ -49,16 +49,16 @@ "y": 1 }, { - "x": 238.78, + "x": 77.67, "y": 1 }, { - "x": 238.78, - "y": 147.67 + "x": 77.67, + "y": 62.11 }, { "x": 1, - "y": 147.67 + "y": 62.11 } ], "label": "S1", @@ -68,8 +68,8 @@ "labelVerticalOffset": 0, "labelRotationAngle": 0, "uuid": "uuid2", - "categoryLabel": null, - "categoryKey": null, + "categoryLabel": "Foo", + "categoryKey": 1, "topLeft": { "x": 0, "y": 0 @@ -83,8 +83,8 @@ "skippedCharacters": [] }, "subChart": { - "height": 149, - "width": 240, + "height": 64, + "width": 79, "tables": [], "texts": [], "imageObjects": [], @@ -109,156 +109,37 @@ }, "seats": [ { - "x": 42.22, - "y": 105, + "x": 21.11, + "y": 29.78, "label": "1", "displayLabel": null, - "categoryLabel": "CatB", + "categoryLabel": "Foo", "categoryAccessible": false, - "categoryKey": 2, + "categoryKey": 1, "restrictedView": false, "viewFromYourSeatImage": null, "accessible": false, "companionSeat": false, "semiAmbulatorySeat": false, "disabledBySocialDistancingRules": false, - "uuid": "uuid5", + "uuid": "uuid3", "published": true }, { - "x": 63.22, - "y": 105, + "x": 42.11, + "y": 29.78, "label": "2", "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid6", - "published": true - }, - { - "x": 84.22, - "y": 105, - "label": "3", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid7", - "published": true - }, - { - "x": 105.22, - "y": 105, - "label": "4", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid8", - "published": true - }, - { - "x": 126.22, - "y": 105, - "label": "5", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid9", - "published": true - }, - { - "x": 147.22, - "y": 105, - "label": "6", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid10", - "published": true - }, - { - "x": 168.22, - "y": 105, - "label": "7", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid11", - "published": true - }, - { - "x": 189.22, - "y": 105, - "label": "8", - "displayLabel": null, - "categoryLabel": "CatB", + "categoryLabel": "Foo", "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "uuid": "uuid12", - "published": true - }, - { - "x": 210.22, - "y": 105, - "label": "9", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, + "categoryKey": 1, "restrictedView": false, "viewFromYourSeatImage": null, "accessible": false, "companionSeat": false, "semiAmbulatorySeat": false, "disabledBySocialDistancingRules": false, - "uuid": "uuid13", + "uuid": "uuid4", "published": true } ], @@ -267,7 +148,7 @@ "verticalRowLabelDirection": "BASELINE_LEFT", "displayObjectType": "row", "objectType": "row", - "uuid": "uuid15", + "uuid": "uuid6", "points": null, "smooth": false, "smoothness": 50, @@ -277,33 +158,7 @@ } ], "shapes": [], - "booths": [ - { - "label": "1", - "displayLabel": null, - "sectionLabel": null, - "sectionDisplayedLabel": null, - "objectLabeling": { - "algoName": "SimpleNumbers", - "prefix": "", - "startAtIndex": 0, - "skippedCharacters": [] - }, - "center": { - "x": 47.78, - "y": 48.33 - }, - "width": 50, - "height": 50, - "rotationAngle": 0, - "categoryLabel": "CatA", - "categoryKey": 1, - "objectType": "booth", - "uuid": "uuid4", - "published": true, - "entrance": null - } - ], + "booths": [], "icons": [], "generalAdmissionAreas": [] }, @@ -315,15 +170,15 @@ "backgroundImage": null, "referenceChart": null, "snapOffset": { - "x": 3, - "y": 2.11 + "x": 2.33, + "y": 2.33 }, "floorDisplayName": "Floor 1", "floorName": "1" }, { - "height": 173.11, - "width": 268.67, + "height": 63.11, + "width": 1294.22, "tables": [], "texts": [], "imageObjects": [], @@ -336,20 +191,20 @@ { "points": [ { - "x": 29.89, - "y": 25.44 + "x": 1243.22, + "y": 13.22 }, { - "x": 267.67, - "y": 25.44 + "x": 1293.22, + "y": 13.22 }, { - "x": 267.67, - "y": 172.11 + "x": 1293.22, + "y": 53.22 }, { - "x": 29.89, - "y": 172.11 + "x": 1243.22, + "y": 53.22 } ], "label": "S2", @@ -358,12 +213,12 @@ "labelHorizontalOffset": 0, "labelVerticalOffset": 0, "labelRotationAngle": 0, - "uuid": "uuid31", - "categoryLabel": null, - "categoryKey": null, + "uuid": "uuid9", + "categoryLabel": "Bar", + "categoryKey": 2, "topLeft": { - "x": 28.89, - "y": 24.44 + "x": 1242.22, + "y": 12.22 }, "entrance": null, "viewFromYourSeatImage": null, @@ -374,14 +229,14 @@ "skippedCharacters": [] }, "subChart": { - "height": 149, - "width": 240, + "height": 42, + "width": 52, "tables": [], "texts": [], "imageObjects": [], "rows": [ { - "label": "A", + "label": "B", "displayLabel": null, "sectionLabel": null, "sectionDisplayedLabel": null, @@ -400,11 +255,11 @@ }, "seats": [ { - "x": 42.22, - "y": 105, + "x": 16, + "y": 19.89, "label": "1", "displayLabel": null, - "categoryLabel": "CatB", + "categoryLabel": "Foo", "categoryAccessible": false, "categoryKey": 2, "restrictedView": false, @@ -413,88 +268,15 @@ "companionSeat": false, "semiAmbulatorySeat": false, "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid34", + "uuid": "uuid10", "published": true }, { - "x": 63.22, - "y": 105, + "x": 37, + "y": 19.89, "label": "2", "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid35", - "published": true - }, - { - "x": 84.22, - "y": 105, - "label": "3", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid36", - "published": true - }, - { - "x": 105.22, - "y": 105, - "label": "4", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid37", - "published": true - }, - { - "x": 126.22, - "y": 105, - "label": "5", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid38", - "published": true - }, - { - "x": 147.22, - "y": 105, - "label": "6", - "displayLabel": null, - "categoryLabel": "CatB", + "categoryLabel": "Foo", "categoryAccessible": false, "categoryKey": 2, "restrictedView": false, @@ -503,62 +285,7 @@ "companionSeat": false, "semiAmbulatorySeat": false, "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid39", - "published": true - }, - { - "x": 168.22, - "y": 105, - "label": "7", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid40", - "published": true - }, - { - "x": 189.22, - "y": 105, - "label": "8", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid41", - "published": true - }, - { - "x": 210.22, - "y": 105, - "label": "9", - "displayLabel": null, - "categoryLabel": "CatB", - "categoryAccessible": false, - "categoryKey": 2, - "restrictedView": false, - "viewFromYourSeatImage": null, - "accessible": false, - "companionSeat": false, - "semiAmbulatorySeat": false, - "disabledBySocialDistancingRules": false, - "entrance": null, - "uuid": "uuid42", + "uuid": "uuid11", "published": true } ], @@ -567,7 +294,7 @@ "verticalRowLabelDirection": "BASELINE_LEFT", "displayObjectType": "row", "objectType": "row", - "uuid": "uuid33", + "uuid": "uuid13", "points": null, "smooth": false, "smoothness": 50, @@ -577,33 +304,7 @@ } ], "shapes": [], - "booths": [ - { - "label": "1", - "displayLabel": null, - "sectionLabel": null, - "sectionDisplayedLabel": null, - "objectLabeling": { - "algoName": "SimpleNumbers", - "prefix": "", - "startAtIndex": 0, - "skippedCharacters": [] - }, - "center": { - "x": 47.78, - "y": 48.33 - }, - "width": 50, - "height": 50, - "rotationAngle": 0, - "categoryLabel": "CatA", - "categoryKey": 1, - "objectType": "booth", - "uuid": "uuid43", - "published": true, - "entrance": null - } - ], + "booths": [], "icons": [], "generalAdmissionAreas": [] }, @@ -615,8 +316,8 @@ "backgroundImage": null, "referenceChart": null, "snapOffset": { - "x": 3, - "y": 2.11 + "x": 2.33, + "y": 2.33 }, "floorDisplayName": "Floor 2", "floorName": "2" @@ -624,4 +325,3 @@ ], "multiFloorView": "isometric" } -