Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3755938
D947.id2412.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.id2412.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
@@ -7,6 +7,8 @@
use Nasqueron\Notifications\Analyzers\ItemGroupMapping;
use Nasqueron\Notifications\Tests\TestCase;
+use File;
+
class ItemGroupMappingTest extends TestCase {
public function testDoesItemMatch () {
@@ -45,4 +47,34 @@
)
);
}
+
+ /**
+ * @dataProvider payloadProvider
+ */
+ public function testDeserialize ($payload, $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
Tue, Nov 19, 19:18 (19 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2252923
Default Alt Text
D947.id2412.diff (2 KB)
Attached To
Mode
D947: Ensure ItemGroupMapping::$items is always an array
Attached
Detach File
Event Timeline
Log In to Comment