diff options
author | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2018-10-02 14:45:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 14:45:36 +0200 |
commit | 21e6f5cd6e4d75655872c58d887d6457530b4b04 (patch) | |
tree | 4f80a00c6a3a0447d6a1375ed8d3ef501bf21109 /tests/Unit/Controller | |
parent | 13fb06e5141e3433ab502565527324ad1e924d00 (diff) | |
parent | 3c3de1756854c95a386e5396cb90424853c4c6ac (diff) |
Merge pull request #283 from danopz/entity-methods
Entity setters + getters
Diffstat (limited to 'tests/Unit/Controller')
-rw-r--r-- | tests/Unit/Controller/EntityApiSerializerTest.php | 20 | ||||
-rw-r--r-- | tests/Unit/Controller/ExportControllerTest.php | 8 | ||||
-rw-r--r-- | tests/Unit/Controller/ItemApiControllerTest.php | 30 |
3 files changed, 46 insertions, 12 deletions
diff --git a/tests/Unit/Controller/EntityApiSerializerTest.php b/tests/Unit/Controller/EntityApiSerializerTest.php index 15f11a8b0..8709275e7 100644 --- a/tests/Unit/Controller/EntityApiSerializerTest.php +++ b/tests/Unit/Controller/EntityApiSerializerTest.php @@ -33,6 +33,10 @@ class EntityApiSerializerTest extends TestCase { $item = new Item(); $item->setUnread(true); + $item->setId(3); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $serializer = new EntityApiSerializer('items'); $result = $serializer->serialize($item); @@ -45,9 +49,17 @@ class EntityApiSerializerTest extends TestCase { $item = new Item(); $item->setUnread(true); + $item->setId(3); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $item2 = new Item(); $item2->setUnread(false); + $item2->setId(5); + $item2->setGuid('guid'); + $item2->setGuidHash('guidhash'); + $item2->setFeedId(123); $serializer = new EntityApiSerializer('items'); @@ -73,9 +85,17 @@ class EntityApiSerializerTest extends TestCase { $item = new Item(); $item->setUnread(true); + $item->setId(3); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $item2 = new Item(); $item2->setUnread(false); + $item2->setId(5); + $item2->setGuid('guid'); + $item2->setGuidHash('guidhash'); + $item2->setFeedId(123); $serializer = new EntityApiSerializer('items'); diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php index 7917eee24..b2b56e8dd 100644 --- a/tests/Unit/Controller/ExportControllerTest.php +++ b/tests/Unit/Controller/ExportControllerTest.php @@ -99,8 +99,10 @@ class ExportControllerTest extends TestCase { $item1 = new Item(); $item1->setFeedId(3); + $item1->setGuid('guid'); $item2 = new Item(); $item2->setFeedId(5); + $item2->setGuid('guid'); $feed1 = new Feed(); $feed1->setId(3); @@ -130,13 +132,13 @@ class ExportControllerTest extends TestCase ); $this->assertEquals( - '[{"guid":null,"url":null,"title":null,' . + '[{"guid":"guid","url":null,"title":null,' . '"author":null,"pubDate":null,"updatedDate":null,"body":null,"enclosureMime":null,' . '"enclosureLink":null,"unread":false,"starred":false,' . - '"feedLink":"http:\/\/goo","rtl":null},{"guid":null,"url":null,' . + '"feedLink":"http:\/\/goo","rtl":false},{"guid":"guid","url":null,' . '"title":null,"author":null,"pubDate":null,"updatedDate":null,"body":null,' . '"enclosureMime":null,"enclosureLink":null,"unread":false,' . - '"starred":false,"feedLink":"http:\/\/gee","rtl":null}]', + '"starred":false,"feedLink":"http:\/\/gee","rtl":false}]', $return->render() ); } diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index 916b85a36..1e6fde59b 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -77,7 +77,11 @@ class ItemApiControllerTest extends TestCase public function testIndex() { - $items = [new Item()]; + $item = new Item(); + $item->setId(5); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $this->itemService->expects($this->once()) ->method('findAll') @@ -90,13 +94,13 @@ class ItemApiControllerTest extends TestCase $this->equalTo(true), $this->equalTo($this->user->getUID()) ) - ->will($this->returnValue($items)); + ->will($this->returnValue([$item])); $response = $this->itemAPI->index(1, 2, true, 30, 20, true); $this->assertEquals( [ - 'items' => [$items[0]->toApi()] + 'items' => [$item->toApi()] ], $response ); } @@ -104,7 +108,11 @@ class ItemApiControllerTest extends TestCase public function testIndexDefaultBatchSize() { - $items = [new Item()]; + $item = new Item(); + $item->setId(5); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $this->itemService->expects($this->once()) ->method('findAll') @@ -117,13 +125,13 @@ class ItemApiControllerTest extends TestCase $this->equalTo(false), $this->equalTo($this->user->getUID()) ) - ->will($this->returnValue($items)); + ->will($this->returnValue([$item])); $response = $this->itemAPI->index(1, 2, false); $this->assertEquals( [ - 'items' => [$items[0]->toApi()] + 'items' => [$item->toApi()] ], $response ); } @@ -131,7 +139,11 @@ class ItemApiControllerTest extends TestCase public function testUpdated() { - $items = [new Item()]; + $item = new Item(); + $item->setId(5); + $item->setGuid('guid'); + $item->setGuidHash('guidhash'); + $item->setFeedId(123); $this->itemService->expects($this->once()) ->method('findAllNew') @@ -142,13 +154,13 @@ class ItemApiControllerTest extends TestCase $this->equalTo(true), $this->equalTo($this->user->getUID()) ) - ->will($this->returnValue($items)); + ->will($this->returnValue([$item])); $response = $this->itemAPI->updated(1, 2, 30); $this->assertEquals( [ - 'items' => [$items[0]->toApi()] + 'items' => [$item->toApi()] ], $response ); } |