summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-08-06 14:11:03 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-08-06 14:11:03 +0200
commit05d38a2b745b49b2fb2f11537a18fcd37b9eba55 (patch)
treeadaac0c9ab0f70137d7558ca07fa44a48f84e9a8
parent08a281f552036a82f3a4b82bcdbd6e6fd9be4798 (diff)
use a default batchsize of 20 if none given, fix #220
-rw-r--r--CHANGELOG1
-rw-r--r--external/itemapi.php2
-rw-r--r--tests/unit/external/ItemAPITest.php39
3 files changed, 41 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2a3bbd7c2..6b243c31a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ owncloud-news (1.203)
* Make it possible to turn off cron updates
* Strip all HTML tags from the author and title
* Sanitize urls on the server side to prevent clients from being affected by XSS
+* Use a default batch value for the API
ownCloud-news (1.202)
* Fixed a bug in the API routes that would request an uneeded id when creating a feed
diff --git a/external/itemapi.php b/external/itemapi.php
index 83aa0f4da..0477f3a19 100644
--- a/external/itemapi.php
+++ b/external/itemapi.php
@@ -60,7 +60,7 @@ class ItemAPI extends Controller {
);
$userId = $this->api->getUserId();
- $batchSize = (int) $this->params('batchSize');
+ $batchSize = (int) $this->params('batchSize', 20);
$offset = (int) $this->params('offset', 0);
$type = (int) $this->params('type');
$id = (int) $this->params('id');
diff --git a/tests/unit/external/ItemAPITest.php b/tests/unit/external/ItemAPITest.php
index ee5f22c2d..6bc5128c7 100644
--- a/tests/unit/external/ItemAPITest.php
+++ b/tests/unit/external/ItemAPITest.php
@@ -170,6 +170,45 @@ class ItemAPITest extends ControllerTestUtility {
}
+ public function testGetAllDefaultBatchSize() {
+ $items = array(
+ new Item()
+ );
+ $request = new Request(array('params' => array(
+ 'offset' => 20,
+ 'type' => 1,
+ 'id' => 2,
+ 'getRead' => 'false'
+ )));
+ $this->itemAPI = new ItemAPI(
+ $this->api,
+ $request,
+ $this->itemBusinessLayer
+ );
+
+ $this->api->expects($this->once())
+ ->method('getUserId')
+ ->will($this->returnValue($this->user));
+ $this->itemBusinessLayer->expects($this->once())
+ ->method('findAll')
+ ->with(
+ $this->equalTo(2),
+ $this->equalTo(1),
+ $this->equalTo(20),
+ $this->equalTo(20),
+ $this->equalTo(false),
+ $this->equalTo($this->user)
+ )
+ ->will($this->returnValue($items));
+
+ $response = $this->itemAPI->getAll();
+
+ $this->assertEquals(array(
+ 'items' => array($items[0]->toAPI())
+ ), $response->getData());
+ }
+
+
public function testGetUpdated() {
$items = array(
new Item()