Page MenuHomeDevCentral

D947.id2413.diff
No OneTemporary

D947.id2413.diff

diff --git a/app/Analyzers/ItemGroupMapping.php b/app/Analyzers/ItemGroupMapping.php
--- a/app/Analyzers/ItemGroupMapping.php
+++ b/app/Analyzers/ItemGroupMapping.php
@@ -25,7 +25,7 @@
*
* @var array
*/
- public $items;
+ public $items = [];
///
/// Helper methods
diff --git a/tests/Analyzers/ItemGroupMappingTest.php b/tests/Analyzers/ItemGroupMappingTest.php
--- a/tests/Analyzers/ItemGroupMappingTest.php
+++ b/tests/Analyzers/ItemGroupMappingTest.php
@@ -45,4 +45,34 @@
)
);
}
+
+ /**
+ * @dataProvider payloadProvider
+ */
+ public function testDeserialize (ItemGroupMapping $payload, ItemGroupMapping $expected) {
+ $this->assertEquals($payload, $expected);
+ }
+
+ private function deserialize ($file) : ItemGroupMapping {
+ $mapper = new \JsonMapper();
+ $payload = json_decode(file_get_contents($file));
+ return $mapper->map($payload, new ItemGroupMapping);
+ }
+
+ public function payloadProvider () : array {
+ $toProvide = [];
+
+ $path = __DIR__ . '/../data/ItemGroupMapping';
+ $files = glob($path . "/*.expected.json");
+ foreach ($files as $expectedResultFile) {
+ $resultFile = str_replace(".expected", "", $expectedResultFile);
+ $toProvide[] = [
+ $this->deserialize($resultFile),
+ $this->deserialize($expectedResultFile),
+ ];
+ }
+
+ return $toProvide;
+ }
+
}
diff --git a/tests/data/ItemGroupMapping/incomplete.expected.json b/tests/data/ItemGroupMapping/incomplete.expected.json
new file mode 100644
--- /dev/null
+++ b/tests/data/ItemGroupMapping/incomplete.expected.json
@@ -0,0 +1,4 @@
+{
+ "group": "tasacora",
+ "items": []
+}
diff --git a/tests/data/ItemGroupMapping/incomplete.json b/tests/data/ItemGroupMapping/incomplete.json
new file mode 100644
--- /dev/null
+++ b/tests/data/ItemGroupMapping/incomplete.json
@@ -0,0 +1,3 @@
+{
+ "group": "tasacora"
+}
diff --git a/tests/data/ItemGroupMapping/regular.expected.json b/tests/data/ItemGroupMapping/regular.expected.json
new file mode 100644
--- /dev/null
+++ b/tests/data/ItemGroupMapping/regular.expected.json
@@ -0,0 +1,6 @@
+{
+ "group": "tasacora",
+ "items": [
+ "Tasacora"
+ ]
+}
diff --git a/tests/data/ItemGroupMapping/regular.json b/tests/data/ItemGroupMapping/regular.json
new file mode 100644
--- /dev/null
+++ b/tests/data/ItemGroupMapping/regular.json
@@ -0,0 +1,6 @@
+{
+ "group": "tasacora",
+ "items": [
+ "Tasacora"
+ ]
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 19, 18:42 (18 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251295
Default Alt Text
D947.id2413.diff (2 KB)

Event Timeline