Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3752868
D947.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D947.id.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 21:49 (5 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251295
Default Alt Text
D947.id.diff (2 KB)
Attached To
Mode
D947: Ensure ItemGroupMapping::$items is always an array
Attached
Detach File
Event Timeline
Log In to Comment