diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-02 21:03:33 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-02 21:03:33 +0200 |
commit | ec8394eda1b1769b3cf1032fc03a107092b222a4 (patch) | |
tree | bcf13ab35f8b0accc4e30a466b9a5c0233648c3e /tests/unit | |
parent | 2b42d8bd9e54afa35d0e8b6cfd67183e3d3d00a8 (diff) |
add read button
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/external/ItemAPITest.php | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/tests/unit/external/ItemAPITest.php b/tests/unit/external/ItemAPITest.php index e8fe747d5..c91b06db7 100644 --- a/tests/unit/external/ItemAPITest.php +++ b/tests/unit/external/ItemAPITest.php @@ -54,12 +54,15 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { '\OCA\News\BusinessLayer\ItemBusinessLayer') ->disableOriginalConstructor() ->getMock(); + $this->user = 'tom'; + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); $this->itemAPI = new ItemAPI( $this->api, $this->request, $this->itemBusinessLayer ); - $this->user = 'tom'; } @@ -80,9 +83,6 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer ); - $this->api->expects($this->once()) - ->method('getUserId') - ->will($this->returnValue($this->user)); $this->itemBusinessLayer->expects($this->once()) ->method('findAll') ->with( @@ -103,5 +103,63 @@ class ItemAPITest extends \PHPUnit_Framework_TestCase { } + public function testGetUpdated() { + $items = array( + new Item() + ); + $request = new Request(array('params' => array( + 'lastModified' => 30, + 'type' => 1, + 'id' => 2, + ))); + $this->itemAPI = new ItemAPI( + $this->api, + $request, + $this->itemBusinessLayer + ); + + $this->itemBusinessLayer->expects($this->once()) + ->method('findAllNew') + ->with( + $this->equalTo(2), + $this->equalTo(1), + $this->equalTo(30), + $this->equalTo(true), + $this->equalTo($this->user) + ) + ->will($this->returnValue($items)); + + $response = $this->itemAPI->getUpdated(); + + $this->assertEquals(array( + 'items' => array($items[0]->toAPI()) + ), $response->getData()); + } + + + public function testRead() { + $request = new Request(array('urlParams' => array( + 'itemId' => 2 + ))); + $this->itemAPI = new ItemAPI( + $this->api, + $request, + $this->itemBusinessLayer + ); + + $this->itemBusinessLayer->expects($this->once()) + ->method('read') + ->with( + $this->equalTo(2), + $this->equalTo(true), + $this->equalTo($this->user) + ); + + $response = $this->itemAPI->read(); + + $this->assertNull($response->getData()); + $this->assertNull($response->getMessage()); + $this->assertEquals(NewsAPIResult::OK, $response->getStatusCode()); + } }
\ No newline at end of file |