summaryrefslogtreecommitdiffstats
path: root/tests/unit/controller/EntityApiSerializerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/controller/EntityApiSerializerTest.php')
-rw-r--r--tests/unit/controller/EntityApiSerializerTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/controller/EntityApiSerializerTest.php b/tests/unit/controller/EntityApiSerializerTest.php
new file mode 100644
index 000000000..8153f40d6
--- /dev/null
+++ b/tests/unit/controller/EntityApiSerializerTest.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Alessandro Cosentino 2012
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+
+namespace OCA\News\Controller;
+
+require_once(__DIR__ . "/../../classloader.php");
+
+use \OCA\News\Db\Item;
+
+
+class EntityApiSerializerTest extends \PHPUnit_Framework_TestCase {
+
+
+ public function testSerializeSingle() {
+ $item = new Item();
+ $item->setUnread();
+
+ $serializer = new EntityApiSerializer('items');
+ $result = $serializer->serialize($item);
+
+ $this->assertTrue($result['items'][0]['unread']);
+ }
+
+
+ public function testSerializeMultiple() {
+ $item = new Item();
+ $item->setUnread();
+
+ $item2 = new Item();
+ $item2->setRead();
+
+ $serializer = new EntityApiSerializer('items');
+ $result = $serializer->serialize(array($item, $item2));
+
+ $this->assertTrue($result['items'][0]['unread']);
+ $this->assertFalse($result['items'][1]['unread']);
+ }
+
+
+} \ No newline at end of file