1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-04-12 19:15:43 +02:00

also send newest item id when creating a feed from the api

This commit is contained in:
Bernhard Posselt 2013-05-09 13:44:16 +02:00
parent c894577781
commit 59069e85a2
2 changed files with 54 additions and 2 deletions
external
tests/unit/external

12
external/feedapi.php vendored
View File

@ -83,9 +83,17 @@ class FeedAPI extends Controller {
try {
$feed = $this->feedBusinessLayer->create($feedUrl, $folderId, $userId);
return new NewsAPIResult(array(
$result = array(
'feeds' => array($feed->toAPI())
));
);
try {
$result['newestItemId'] =
$this->itemBusinessLayer->getNewestItemId($userId);
} catch(BusinessLayerException $ex) {}
return new NewsAPIResult($result);
} catch(BusinessLayerExistsException $ex) {
return new NewsAPIResult(null, NewsAPIResult::EXISTS_ERROR,
$ex->getMessage());

View File

@ -217,6 +217,49 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase {
$this->equalTo(3),
$this->equalTo($this->user))
->will($this->returnValue($feeds[0]));
$this->itemBusinessLayer->expects($this->once())
->method('getNewestItemId')
->will($this->returnValue(3));
$response = $this->feedAPI->create();
$this->assertEquals(array(
'feeds' => array($feeds[0]->toAPI()),
'newestItemId' => 3
), $response->getData());
$this->assertNull($response->getMessage());
$this->assertEquals(NewsAPIResult::OK, $response->getStatusCode());
}
public function testCreateNoItems() {
$feeds = array(
new Feed()
);
$request = new Request(array('params' => array(
'url' => 'ho',
'folderId' => 3
)));
$this->feedAPI = new FeedAPI(
$this->api,
$request,
$this->folderBusinessLayer,
$this->feedBusinessLayer,
$this->itemBusinessLayer
);
$this->feedBusinessLayer->expects($this->once())
->method('create')
->with(
$this->equalTo('ho'),
$this->equalTo(3),
$this->equalTo($this->user))
->will($this->returnValue($feeds[0]));
$this->itemBusinessLayer->expects($this->once())
->method('getNewestItemId')
->will($this->throwException(new BusinessLayerException('')));
$response = $this->feedAPI->create();
@ -229,6 +272,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase {
}
public function testCreateExists() {
$this->feedBusinessLayer->expects($this->once())
->method('create')