1
0
mirror of https://github.com/chylex/Nextcloud-News.git synced 2025-05-10 19:34:06 +02:00

Controllers: Use v2 services

Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
This commit is contained in:
Sean Molenaar 2020-11-03 21:56:37 +01:00 committed by Sean Molenaar
parent ab149a7870
commit af2fd96825
15 changed files with 419 additions and 234 deletions

View File

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Upload codecoverage to codecov.io - Upload codecoverage to codecov.io
- Use foreign keys in db - Use foreign keys in db
- Fix delete api not working - Fix delete api not working
- Move controllers to use V2 services
## 15.0.6 ## 15.0.6

157
composer.lock generated
View File

@ -57,6 +57,10 @@
"html", "html",
"readability" "readability"
], ],
"support": {
"issues": "https://github.com/andreskrey/readability.php/issues",
"source": "https://github.com/andreskrey/readability.php/tree/v2.1.0"
},
"time": "2019-07-22T21:42:25+00:00" "time": "2019-07-22T21:42:25+00:00"
}, },
{ {
@ -110,6 +114,11 @@
"finder", "finder",
"icon" "icon"
], ],
"support": {
"issues": "https://github.com/ArthurHoaro/favicon/issues",
"source": "https://github.com/ArthurHoaro/favicon/tree/v1.3.1",
"sources": "https://github.com/ArthurHoaro/favicon"
},
"time": "2020-10-14T09:32:44+00:00" "time": "2020-10-14T09:32:44+00:00"
}, },
{ {
@ -173,6 +182,10 @@
"news", "news",
"rss" "rss"
], ],
"support": {
"issues": "https://github.com/alexdebril/feed-io/issues",
"source": "https://github.com/alexdebril/feed-io/tree/v4.7.10"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/alexdebril", "url": "https://github.com/alexdebril",
@ -229,6 +242,10 @@
"keywords": [ "keywords": [
"html" "html"
], ],
"support": {
"issues": "https://github.com/ezyang/htmlpurifier/issues",
"source": "https://github.com/ezyang/htmlpurifier/tree/master"
},
"time": "2020-06-29T00:56:53+00:00" "time": "2020-06-29T00:56:53+00:00"
}, },
{ {
@ -293,6 +310,10 @@
"uri", "uri",
"url" "url"
], ],
"support": {
"issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2",
"source": "https://github.com/pear/Net_URL2"
},
"time": "2017-08-25T06:16:11+00:00" "time": "2017-08-25T06:16:11+00:00"
}, },
{ {
@ -340,6 +361,9 @@
"psr", "psr",
"psr-3" "psr-3"
], ],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.3"
},
"time": "2020-03-23T09:12:05+00:00" "time": "2020-03-23T09:12:05+00:00"
}, },
{ {
@ -390,6 +414,10 @@
"path", "path",
"system" "system"
], ],
"support": {
"issues": "https://github.com/Riimu/Kit-PathJoin/issues",
"source": "https://github.com/Riimu/Kit-PathJoin/tree/master"
},
"time": "2017-07-09T14:41:04+00:00" "time": "2017-07-09T14:41:04+00:00"
}, },
{ {
@ -504,6 +532,10 @@
"constructor", "constructor",
"instantiate" "instantiate"
], ],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.3.x"
},
"funding": [ "funding": [
{ {
"url": "https://www.doctrine-project.org/sponsorship.html", "url": "https://www.doctrine-project.org/sponsorship.html",
@ -566,6 +598,10 @@
"object", "object",
"object graph" "object graph"
], ],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.x"
},
"funding": [ "funding": [
{ {
"url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
@ -627,6 +663,10 @@
} }
], ],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/master"
},
"time": "2018-07-08T19:23:20+00:00" "time": "2018-07-08T19:23:20+00:00"
}, },
{ {
@ -674,6 +714,10 @@
} }
], ],
"description": "Library for handling version information and constraints", "description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/master"
},
"time": "2018-07-08T19:19:57+00:00" "time": "2018-07-08T19:19:57+00:00"
}, },
{ {
@ -723,6 +767,10 @@
"reflection", "reflection",
"static analysis" "static analysis"
], ],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
},
"time": "2020-06-27T09:03:43+00:00" "time": "2020-06-27T09:03:43+00:00"
}, },
{ {
@ -775,6 +823,10 @@
} }
], ],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
},
"time": "2020-09-03T19:13:55+00:00" "time": "2020-09-03T19:13:55+00:00"
}, },
{ {
@ -820,6 +872,10 @@
} }
], ],
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
},
"time": "2020-09-17T18:55:26+00:00" "time": "2020-09-17T18:55:26+00:00"
}, },
{ {
@ -883,6 +939,10 @@
"spy", "spy",
"stub" "stub"
], ],
"support": {
"issues": "https://github.com/phpspec/prophecy/issues",
"source": "https://github.com/phpspec/prophecy/tree/1.12.1"
},
"time": "2020-09-29T09:10:42+00:00" "time": "2020-09-29T09:10:42+00:00"
}, },
{ {
@ -925,6 +985,10 @@
"MIT" "MIT"
], ],
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.53"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/ondrejmirtes", "url": "https://github.com/ondrejmirtes",
@ -1003,6 +1067,10 @@
"testing", "testing",
"xunit" "xunit"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/8.0.2"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1059,6 +1127,10 @@
"filesystem", "filesystem",
"iterator" "iterator"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1118,6 +1190,10 @@
"keywords": [ "keywords": [
"process" "process"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
"source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1173,6 +1249,10 @@
"keywords": [ "keywords": [
"template" "template"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
"source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1228,6 +1308,10 @@
"keywords": [ "keywords": [
"timer" "timer"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
"source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1283,6 +1367,10 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/php-token-stream/issues",
"source": "https://github.com/sebastianbergmann/php-token-stream/tree/master"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1378,6 +1466,10 @@
"testing", "testing",
"xunit" "xunit"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.2.6"
},
"funding": [ "funding": [
{ {
"url": "https://phpunit.de/donate.html", "url": "https://phpunit.de/donate.html",
@ -1434,6 +1526,10 @@
], ],
"description": "Collection of value objects that represent the PHP code units", "description": "Collection of value objects that represent the PHP code units",
"homepage": "https://github.com/sebastianbergmann/code-unit", "homepage": "https://github.com/sebastianbergmann/code-unit",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
"source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1485,6 +1581,10 @@
], ],
"description": "Looks up which function or method a line of code belongs to", "description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1555,6 +1655,10 @@
"compare", "compare",
"equality" "equality"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1617,6 +1721,10 @@
"unidiff", "unidiff",
"unified diff" "unified diff"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1676,6 +1784,10 @@
"environment", "environment",
"hhvm" "hhvm"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1749,6 +1861,10 @@
"export", "export",
"exporter" "exporter"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1809,6 +1925,10 @@
"keywords": [ "keywords": [
"global state" "global state"
], ],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/master"
},
"time": "2020-02-07T06:11:37+00:00" "time": "2020-02-07T06:11:37+00:00"
}, },
{ {
@ -1856,6 +1976,10 @@
], ],
"description": "Traverses array structures and object graphs to enumerate all referenced objects", "description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/", "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1907,6 +2031,10 @@
], ],
"description": "Allows reflection of object attributes, including inherited and non-public ones", "description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/", "homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
"source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -1966,6 +2094,10 @@
], ],
"description": "Provides functionality to recursively process PHP variables", "description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context", "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -2017,6 +2149,10 @@
], ],
"description": "Provides a list of PHP built-in functions that operate on resources", "description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations", "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
"source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -2069,6 +2205,10 @@
], ],
"description": "Collection of value objects that represent the types of the PHP type system", "description": "Collection of value objects that represent the types of the PHP type system",
"homepage": "https://github.com/sebastianbergmann/type", "homepage": "https://github.com/sebastianbergmann/type",
"support": {
"issues": "https://github.com/sebastianbergmann/type/issues",
"source": "https://github.com/sebastianbergmann/type/tree/2.3.1"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -2118,6 +2258,10 @@
], ],
"description": "Library that helps with managing the version number of Git-hosted PHP projects", "description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version", "homepage": "https://github.com/sebastianbergmann/version",
"support": {
"issues": "https://github.com/sebastianbergmann/version/issues",
"source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/sebastianbergmann", "url": "https://github.com/sebastianbergmann",
@ -2186,6 +2330,9 @@
"polyfill", "polyfill",
"portable" "portable"
], ],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0"
},
"funding": [ "funding": [
{ {
"url": "https://symfony.com/sponsor", "url": "https://symfony.com/sponsor",
@ -2240,6 +2387,10 @@
} }
], ],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
"source": "https://github.com/theseer/tokenizer/tree/master"
},
"funding": [ "funding": [
{ {
"url": "https://github.com/theseer", "url": "https://github.com/theseer",
@ -2295,6 +2446,10 @@
"check", "check",
"validate" "validate"
], ],
"support": {
"issues": "https://github.com/webmozart/assert/issues",
"source": "https://github.com/webmozart/assert/tree/master"
},
"time": "2020-07-08T17:02:28+00:00" "time": "2020-07-08T17:02:28+00:00"
} }
], ],
@ -2312,5 +2467,5 @@
"ext-curl": "*" "ext-curl": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "1.1.0" "plugin-api-version": "2.0.0"
} }

View File

@ -132,7 +132,7 @@ angular.module('YourApp', [])
In general the input parameters can be in the URL or request body, the App Framework doesnt differentiate between them. In general the input parameters can be in the URL or request body, the App Framework doesnt differentiate between them.
So JSON in the request body like: So JSON in the request body like:
```js ```json
{ {
"id": 3 "id": 3
} }
@ -159,7 +159,7 @@ The output is JSON.
* **Route**: /folders * **Route**: /folders
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"folders": [ "folders": [
{ {
@ -177,7 +177,7 @@ Creates a new folder and returns a new folder object
* **Method**: POST * **Method**: POST
* **Route**: /folders * **Route**: /folders
* **Parameters**: * **Parameters**:
```js ```json
{ {
"name": "folder name" "name": "folder name"
} }
@ -186,7 +186,7 @@ Creates a new folder and returns a new folder object
* **HTTP 409**: If the folder exists already * **HTTP 409**: If the folder exists already
* **HTTP 422**: If the folder name is invalid (for instance empty) * **HTTP 422**: If the folder name is invalid (for instance empty)
* **Returns**: * **Returns**:
```js ```json
{ {
"folders": [ "folders": [
{ {
@ -215,7 +215,7 @@ Only the name can be updated
* **Method**: PUT * **Method**: PUT
* **Route**: /folders/{folderId} * **Route**: /folders/{folderId}
* **Parameters**: * **Parameters**:
```js ```json
{ {
"name": "folder name" "name": "folder name"
} }
@ -232,7 +232,7 @@ Only the name can be updated
* **Method**: PUT * **Method**: PUT
* **Route**: /folders/{folderId}/read * **Route**: /folders/{folderId}/read
* **Parameters**: * **Parameters**:
```js ```json
{ {
// mark all items read lower than equal that id // mark all items read lower than equal that id
// this is mean to prevent marking items as read which the client/user does not yet know of // this is mean to prevent marking items as read which the client/user does not yet know of
@ -259,7 +259,7 @@ The following attributes are **not sanitized** meaning: including them in your w
* **Route**: /feeds * **Route**: /feeds
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"feeds": [ "feeds": [
{ {
@ -294,7 +294,7 @@ Creates a new feed and returns the feed
* **Method**: POST * **Method**: POST
* **Route**: /feeds * **Route**: /feeds
* **Parameters**: * **Parameters**:
```js ```json
{ {
"url": "http:\/\/www.cyanogenmod.org\/wp-content\/themes\/cyanogenmod\/images\/favicon.ico", "url": "http:\/\/www.cyanogenmod.org\/wp-content\/themes\/cyanogenmod\/images\/favicon.ico",
"folderId": 81 // id of the parent folder, 0 for root "folderId": 81 // id of the parent folder, 0 for root
@ -304,7 +304,7 @@ Creates a new feed and returns the feed
* **HTTP 409**: If the feed exists already * **HTTP 409**: If the feed exists already
* **HTTP 422**: If the feed cant be read (most likely contains errors) * **HTTP 422**: If the feed cant be read (most likely contains errors)
* **Returns**: * **Returns**:
```js ```json
{ {
"feeds": [ "feeds": [
{ {
@ -341,7 +341,7 @@ Deletes a feed with the id feedId and all of its items
* **Method**: PUT * **Method**: PUT
* **Route**: /feeds/{feedId}/move * **Route**: /feeds/{feedId}/move
* **Parameters**: * **Parameters**:
```js ```json
{ {
"folderId": 0 // id of the parent folder, 0 for root "folderId": 0 // id of the parent folder, 0 for root
} }
@ -356,7 +356,7 @@ Deletes a feed with the id feedId and all of its items
* **Method**: PUT * **Method**: PUT
* **Route**: /feeds/{feedId}/rename * **Route**: /feeds/{feedId}/rename
* **Parameters**: * **Parameters**:
```js ```json
{ {
"feedTitle": 'New Title' "feedTitle": 'New Title'
} }
@ -371,7 +371,7 @@ Deletes a feed with the id feedId and all of its items
* **Method**: PUT * **Method**: PUT
* **Route**: /feeds/{feedId}/read * **Route**: /feeds/{feedId}/read
* **Parameters**: * **Parameters**:
```js ```json
{ {
// mark all items read lower than equal that id // mark all items read lower than equal that id
// this is mean to prevent marking items as read which the client/user does not yet know of // this is mean to prevent marking items as read which the client/user does not yet know of
@ -402,7 +402,7 @@ The following attributes are **not sanitized** meaning: including them in your w
* **Method**: GET * **Method**: GET
* **Route**: /items * **Route**: /items
* **Parameters**: * **Parameters**:
```js ```json
{ {
"batchSize": 10, // the number of items that should be returned, defaults to -1, new in 5.2.3: -1 returns all items "batchSize": 10, // the number of items that should be returned, defaults to -1, new in 5.2.3: -1 returns all items
"offset": 30, // only return older (lower than equal that id) items than the one with id 30 "offset": 30, // only return older (lower than equal that id) items than the one with id 30
@ -413,7 +413,7 @@ The following attributes are **not sanitized** meaning: including them in your w
} }
``` ```
* **Returns**: * **Returns**:
```js ```json
{ {
"items": [ "items": [
{ {
@ -446,7 +446,7 @@ Autopaging would work like this:
* Get the **first 20** items from a feed with **id 12** * Get the **first 20** items from a feed with **id 12**
**GET /items**: **GET /items**:
```js ```json
{ {
"batchSize": 20, "batchSize": 20,
"offset": 0, "offset": 0,
@ -460,7 +460,7 @@ The item with the lowest item id is 43.
* Get the next **20** items: **GET /items**: * Get the next **20** items: **GET /items**:
```js ```json
{ {
"batchSize": 20, "batchSize": 20,
"offset": 43, "offset": 43,
@ -478,7 +478,7 @@ This is used to stay up to date.
* **Method**: GET * **Method**: GET
* **Route**: /items/updated * **Route**: /items/updated
* **Parameters**: * **Parameters**:
```js ```json
{ {
"lastModified": 123231, // returns only items with a lastModified timestamp >= than this one "lastModified": 123231, // returns only items with a lastModified timestamp >= than this one
// this may also return already existing items whose read or starred status // this may also return already existing items whose read or starred status
@ -488,7 +488,7 @@ This is used to stay up to date.
} }
``` ```
* **Returns**: * **Returns**:
```js ```json
{ {
"items": [ "items": [
{ {
@ -526,7 +526,7 @@ This is used to stay up to date.
* **Method**: PUT * **Method**: PUT
* **Route**: /items/read/multiple * **Route**: /items/read/multiple
* **Parameters**: * **Parameters**:
```js ```json
{ {
"items": [2, 3] // ids of the items "items": [2, 3] // ids of the items
} }
@ -547,7 +547,7 @@ This is used to stay up to date.
* **Method**: PUT * **Method**: PUT
* **Route**: /items/unread/multiple * **Route**: /items/unread/multiple
* **Parameters**: * **Parameters**:
```js ```json
{ {
"items": [2, 3] // ids of the items "items": [2, 3] // ids of the items
} }
@ -568,7 +568,7 @@ This is used to stay up to date.
* **Method**: PUT * **Method**: PUT
* **Route**: /items/star/multiple * **Route**: /items/star/multiple
* **Parameters**: * **Parameters**:
```js ```json
{ {
"items": [ "items": [
{ {
@ -594,7 +594,7 @@ This is used to stay up to date.
* **Method**: PUT * **Method**: PUT
* **Route**: /items/unstar/multiple * **Route**: /items/unstar/multiple
* **Parameters**: * **Parameters**:
```js ```json
{ {
"items": [ "items": [
{ {
@ -612,7 +612,7 @@ This is used to stay up to date.
* **Method**: PUT * **Method**: PUT
* **Route**: /items/read * **Route**: /items/read
* **Parameters**: * **Parameters**:
```js ```json
{ {
// mark all items read lower than equal that id // mark all items read lower than equal that id
// this is mean to prevent marking items as read which the client/user does not yet know of // this is mean to prevent marking items as read which the client/user does not yet know of
@ -657,7 +657,7 @@ This is used to clean up the database. It deletes folders and feeds that are mar
* **Route**: /feeds/all * **Route**: /feeds/all
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"feeds": [ "feeds": [
{ {
@ -680,7 +680,7 @@ This is used to clean up the database. It deletes folders and feeds that are mar
* **Method**: GET * **Method**: GET
* **Route**: /feeds/update * **Route**: /feeds/update
* **Parameters**: * **Parameters**:
```js ```json
{ {
"userId": "john", "userId": "john",
"feedId": 3 "feedId": 3
@ -716,7 +716,7 @@ This is used to clean up the database. It removes old read articles which are no
* **Route**: /version * **Route**: /version
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"version": "5.2.3" "version": "5.2.3"
} }
@ -733,7 +733,7 @@ This API can be used to display warnings and errors in your client if the web ap
* **Route**: /status * **Route**: /status
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"version": "5.2.4", "version": "5.2.4",
"warnings": { "warnings": {
@ -756,7 +756,9 @@ If **incorrectDbCharset** is true you should display a warning that database cha
# User # User
This API can be used to retrieve metadata about the current user This API can be used to retrieve metadata about the current user.
DEPRECATED: This API is deprecated, use the Nextcloud APIs instead.
## Get the status ## Get the status
@ -765,7 +767,7 @@ This API can be used to retrieve metadata about the current user
* **Route**: /user * **Route**: /user
* **Parameters**: none * **Parameters**: none
* **Returns**: * **Returns**:
```js ```json
{ {
"userId": "john", "userId": "john",
"displayName": "John Doe", "displayName": "John Doe",

View File

@ -20,8 +20,6 @@ use OCP\IConfig;
use OCP\IRequest; use OCP\IRequest;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCA\News\Service\ItemService;
/** /**
* Class AdminController * Class AdminController
* *
@ -35,28 +33,18 @@ class AdminController extends Controller
*/ */
private $config; private $config;
/**
* @var ItemService
*/
private $itemService;
/** /**
* AdminController constructor. * AdminController constructor.
* *
* @param string $appName The name of the app * @param string $appName The name of the app
* @param IRequest $request The request * @param IRequest $request The request
* @param IConfig $config Config for nextcloud * @param IConfig $config Config for nextcloud
* @param ItemService $itemService Service for items
*/ */
public function __construct( public function __construct(string $appName, IRequest $request, IConfig $config)
string $appName, {
IRequest $request,
IConfig $config,
ItemService $itemService
) {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->config = $config;
$this->itemService = $itemService; $this->config = $config;
} }
/** /**

View File

@ -41,7 +41,7 @@ class ApiController extends BaseApiController
* @param IRequest $request The request * @param IRequest $request The request
* @param IUserSession $userSession The user session * @param IUserSession $userSession The user session
*/ */
public function __construct($appName, IRequest $request, IUserSession $userSession) public function __construct(string $appName, IRequest $request, IUserSession $userSession)
{ {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->userSession = $userSession; $this->userSession = $userSession;

View File

@ -15,12 +15,12 @@
namespace OCA\News\Controller; namespace OCA\News\Controller;
use Exception;
use OCA\News\Service\Exceptions\ServiceConflictException; use OCA\News\Service\Exceptions\ServiceConflictException;
use OCA\News\Service\Exceptions\ServiceNotFoundException; use OCA\News\Service\Exceptions\ServiceNotFoundException;
use OCA\News\Utility\PsrLogger; use OCA\News\Service\FeedServiceV2;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use \OCP\IRequest; use \OCP\IRequest;
use \OCP\ILogger;
use \OCP\IUserSession; use \OCP\IUserSession;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
@ -31,18 +31,25 @@ use function GuzzleHttp\Psr7\uri_for;
class FeedApiController extends ApiController class FeedApiController extends ApiController
{ {
use JSONHttpErrorTrait; use JSONHttpErrorTrait, ApiPayloadTrait;
/** /**
* TODO: Remove
* @var ItemService * @var ItemService
*/ */
private $itemService; private $oldItemService;
/** /**
* @var FeedService * @var FeedServiceV2
*/ */
private $feedService; private $feedService;
/**
* TODO: Remove
* @var FeedService
*/
private $oldFeedService;
/** /**
* @var LoggerInterface * @var LoggerInterface
*/ */
@ -57,15 +64,16 @@ class FeedApiController extends ApiController
string $appName, string $appName,
IRequest $request, IRequest $request,
IUserSession $userSession, IUserSession $userSession,
FeedService $feedService, FeedService $oldFeedService,
ItemService $itemService, FeedServiceV2 $feedService,
ItemService $oldItemService,
LoggerInterface $logger LoggerInterface $logger
) { ) {
parent::__construct($appName, $request, $userSession); parent::__construct($appName, $request, $userSession);
$this->feedService = $feedService; $this->feedService = $feedService;
$this->itemService = $itemService; $this->oldFeedService = $oldFeedService;
$this->oldItemService = $oldItemService;
$this->logger = $logger; $this->logger = $logger;
$this->serializer = new EntityApiSerializer('feeds');
} }
@ -78,20 +86,17 @@ class FeedApiController extends ApiController
{ {
$result = [ $result = [
'starredCount' => $this->itemService->starredCount($this->getUserId()), 'starredCount' => $this->oldItemService->starredCount($this->getUserId()),
'feeds' => $this->feedService->findAllForUser($this->getUserId()) 'feeds' => $this->serialize($this->feedService->findAllForUser($this->getUserId()))
]; ];
try { try {
$result['newestItemId'] = $result['newestItemId'] = $this->oldItemService->getNewestItemId($this->getUserId());
$this->itemService->getNewestItemId($this->getUserId());
// in case there are no items, ignore
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
// in case there are no items, ignore
} }
return $this->serializer->serialize($result); return $result;
} }
@ -112,20 +117,18 @@ class FeedApiController extends ApiController
} }
try { try {
$this->feedService->purgeDeleted($this->getUserId(), false); $this->feedService->purgeDeleted();
$feed = $this->feedService->create($url, $folderId, $this->getUserId()); $feed = $this->feedService->create($this->getUserId(), $url, $folderId);
$result = ['feeds' => [$feed]]; $result = ['feeds' => $this->serialize($feed)];
try { try {
$result['newestItemId'] = $result['newestItemId'] = $this->oldItemService->getNewestItemId($this->getUserId());
$this->itemService->getNewestItemId($this->getUserId());
// in case there are no items, ignore
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
// in case there are no items, ignore
} }
return $this->serializer->serialize($result); return $result;
} catch (ServiceConflictException $ex) { } catch (ServiceConflictException $ex) {
return $this->error($ex, Http::STATUS_CONFLICT); return $this->error($ex, Http::STATUS_CONFLICT);
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
@ -165,7 +168,7 @@ class FeedApiController extends ApiController
*/ */
public function read(int $feedId, int $newestItemId): void public function read(int $feedId, int $newestItemId): void
{ {
$this->itemService->readFeed($feedId, $newestItemId, $this->getUserId()); $this->oldItemService->readFeed($feedId, $newestItemId, $this->getUserId());
} }
@ -186,7 +189,7 @@ class FeedApiController extends ApiController
} }
try { try {
$this->feedService->patch( $this->oldFeedService->patch(
$feedId, $feedId,
$this->getUserId(), $this->getUserId(),
['folderId' => $folderId] ['folderId' => $folderId]
@ -212,7 +215,7 @@ class FeedApiController extends ApiController
public function rename(int $feedId, string $feedTitle) public function rename(int $feedId, string $feedTitle)
{ {
try { try {
$this->feedService->patch( $this->oldFeedService->patch(
$feedId, $feedId,
$this->getUserId(), $this->getUserId(),
['title' => $feedTitle] ['title' => $feedTitle]
@ -231,7 +234,7 @@ class FeedApiController extends ApiController
*/ */
public function fromAllUsers(): array public function fromAllUsers(): array
{ {
$feeds = $this->feedService->findAllFromAllUsers(); $feeds = $this->feedService->findAll();
$result = ['feeds' => []]; $result = ['feeds' => []];
foreach ($feeds as $feed) { foreach ($feeds as $feed) {
@ -254,9 +257,10 @@ class FeedApiController extends ApiController
public function update(string $userId, int $feedId): void public function update(string $userId, int $feedId): void
{ {
try { try {
$this->feedService->update($userId, $feedId); $feed = $this->feedService->find($userId, $feedId);
$this->feedService->fetch($feed);
// ignore update failure // ignore update failure
} catch (\Exception $ex) { } catch (Exception $ex) {
$this->logger->debug('Could not update feed ' . $ex->getMessage()); $this->logger->debug('Could not update feed ' . $ex->getMessage());
} }
} }

View File

@ -30,8 +30,11 @@ class FeedController extends Controller
{ {
use JSONHttpErrorTrait; use JSONHttpErrorTrait;
//TODO: Remove
private $feedService; private $feedService;
//TODO: Remove
private $folderService; private $folderService;
//TODO: Remove
private $itemService; private $itemService;
private $userId; private $userId;
private $settings; private $settings;

View File

@ -20,31 +20,31 @@ use \OCP\IRequest;
use \OCP\IUserSession; use \OCP\IUserSession;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
use \OCA\News\Service\FolderService;
use \OCA\News\Service\ItemService; use \OCA\News\Service\ItemService;
use \OCA\News\Service\FolderServiceV2;
use \OCA\News\Service\Exceptions\ServiceNotFoundException; use \OCA\News\Service\Exceptions\ServiceNotFoundException;
use \OCA\News\Service\Exceptions\ServiceConflictException; use \OCA\News\Service\Exceptions\ServiceConflictException;
use \OCA\News\Service\Exceptions\ServiceValidationException; use \OCA\News\Service\Exceptions\ServiceValidationException;
class FolderApiController extends ApiController class FolderApiController extends ApiController
{ {
use JSONHttpErrorTrait; use JSONHttpErrorTrait, ApiPayloadTrait;
private $folderService; private $folderService;
//TODO: Remove
private $itemService; private $itemService;
private $serializer;
public function __construct( public function __construct(
string $appName, string $appName,
IRequest $request, IRequest $request,
IUserSession $userSession, IUserSession $userSession,
FolderService $folderService, FolderServiceV2 $folderService,
ItemService $itemService ItemService $itemService
) { ) {
parent::__construct($appName, $request, $userSession); parent::__construct($appName, $request, $userSession);
$this->folderService = $folderService; $this->folderService = $folderService;
$this->itemService = $itemService; $this->itemService = $itemService;
$this->serializer = new EntityApiSerializer('folders');
} }
@ -55,9 +55,8 @@ class FolderApiController extends ApiController
*/ */
public function index() public function index()
{ {
return $this->serializer->serialize( $folders = $this->folderService->findAllForUser($this->getUserId());
$this->folderService->findAllForUser($this->getUserId()) return ['folders' => $this->serialize($folders)];
);
} }
@ -73,10 +72,9 @@ class FolderApiController extends ApiController
public function create(string $name) public function create(string $name)
{ {
try { try {
$this->folderService->purgeDeleted($this->getUserId(), false); $this->folderService->purgeDeleted();
return $this->serializer->serialize( $folder = $this->folderService->create($this->getUserId(), $name);
$this->folderService->create($name, $this->getUserId()) return ['folders' => $this->serialize($folder)];
);
} catch (ServiceValidationException $ex) { } catch (ServiceValidationException $ex) {
return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY);
} catch (ServiceConflictException $ex) { } catch (ServiceConflictException $ex) {
@ -101,7 +99,7 @@ class FolderApiController extends ApiController
} }
try { try {
$this->folderService->delete($folderId, $this->getUserId()); $this->folderService->delete($this->getUserId(), $folderId);
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND); return $this->error($ex, Http::STATUS_NOT_FOUND);
} }
@ -127,7 +125,7 @@ class FolderApiController extends ApiController
} }
try { try {
$this->folderService->rename($folderId, $name, $this->getUserId()); $this->folderService->rename($this->getUserId(), $folderId, $name);
} catch (ServiceValidationException $ex) { } catch (ServiceValidationException $ex) {
return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY); return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY);
} catch (ServiceConflictException $ex) { } catch (ServiceConflictException $ex) {

View File

@ -30,8 +30,11 @@ class FolderController extends Controller
{ {
use JSONHttpErrorTrait; use JSONHttpErrorTrait;
//TODO: Remove
private $folderService; private $folderService;
//TODO: Remove
private $feedService; private $feedService;
//TODO: Remove
private $itemService; private $itemService;
private $userId; private $userId;

View File

@ -15,30 +15,33 @@
namespace OCA\News\Controller; namespace OCA\News\Controller;
use OCA\News\Service\ItemService;
use OCA\News\Service\ItemServiceV2;
use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\JSONResponse;
use \OCP\IRequest; use \OCP\IRequest;
use \OCP\IUserSession; use \OCP\IUserSession;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
use \OCA\News\Service\ItemService;
use \OCA\News\Service\Exceptions\ServiceNotFoundException; use \OCA\News\Service\Exceptions\ServiceNotFoundException;
class ItemApiController extends ApiController class ItemApiController extends ApiController
{ {
use JSONHttpErrorTrait; use JSONHttpErrorTrait, ApiPayloadTrait;
private $oldItemService;
private $itemService; private $itemService;
private $serializer;
public function __construct( public function __construct(
string $appName, string $appName,
IRequest $request, IRequest $request,
IUserSession $userSession, IUserSession $userSession,
ItemService $itemService ItemService $oldItemService,
ItemServiceV2 $itemService
) { ) {
parent::__construct($appName, $request, $userSession); parent::__construct($appName, $request, $userSession);
$this->oldItemService = $oldItemService;
$this->itemService = $itemService; $this->itemService = $itemService;
$this->serializer = new EntityApiSerializer('items');
} }
@ -63,17 +66,17 @@ class ItemApiController extends ApiController
int $offset = 0, int $offset = 0,
bool $oldestFirst = false bool $oldestFirst = false
) { ) {
return $this->serializer->serialize( $items = $this->oldItemService->findAllItems(
$this->itemService->findAllItems( $id,
$id, $type,
$type, $batchSize,
$batchSize, $offset,
$offset, $getRead,
$getRead, $oldestFirst,
$oldestFirst, $this->getUserId()
$this->getUserId()
)
); );
return ['items' => $this->serialize($items)];
} }
@ -87,7 +90,7 @@ class ItemApiController extends ApiController
* @param int $lastModified * @param int $lastModified
* @return array|mixed * @return array|mixed
*/ */
public function updated($type = 3, $id = 0, $lastModified = 0) public function updated(int $type = 3, int $id = 0, int $lastModified = 0)
{ {
// needs to be turned into a millisecond timestamp to work properly // needs to be turned into a millisecond timestamp to work properly
if (strlen((string) $lastModified) <= 10) { if (strlen((string) $lastModified) <= 10) {
@ -95,22 +98,22 @@ class ItemApiController extends ApiController
} else { } else {
$paddedLastModified = $lastModified; $paddedLastModified = $lastModified;
} }
return $this->serializer->serialize( $items = $this->oldItemService->findAllNew(
$this->itemService->findAllNew( $id,
$id, $type,
$type, $paddedLastModified,
$paddedLastModified, true,
true, $this->getUserId()
$this->getUserId()
)
); );
return ['items' => $this->serialize($items)];
} }
private function setRead($isRead, $itemId) private function setRead(bool $isRead, int $itemId)
{ {
try { try {
$this->itemService->read($itemId, $isRead, $this->getUserId()); $this->oldItemService->read($itemId, $isRead, $this->getUserId());
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND); return $this->error($ex, Http::STATUS_NOT_FOUND);
} }
@ -149,10 +152,10 @@ class ItemApiController extends ApiController
} }
private function setStarred($isStarred, $feedId, $guidHash) private function setStarred(bool $isStarred, int $feedId, string $guidHash)
{ {
try { try {
$this->itemService->star( $this->oldItemService->star(
$feedId, $feedId,
$guidHash, $guidHash,
$isStarred, $isStarred,
@ -207,15 +210,15 @@ class ItemApiController extends ApiController
*/ */
public function readAll(int $newestItemId) public function readAll(int $newestItemId)
{ {
$this->itemService->readAll($newestItemId, $this->getUserId()); $this->oldItemService->readAll($newestItemId, $this->getUserId());
} }
private function setMultipleRead($isRead, $items) private function setMultipleRead(bool $isRead, array $items)
{ {
foreach ($items as $id) { foreach ($items as $id) {
try { try {
$this->itemService->read($id, $isRead, $this->getUserId()); $this->oldItemService->read($id, $isRead, $this->getUserId());
} catch (ServiceNotFoundException $ex) { } catch (ServiceNotFoundException $ex) {
continue; continue;
} }
@ -249,11 +252,15 @@ class ItemApiController extends ApiController
} }
private function setMultipleStarred($isStarred, $items) /**
* @param bool $isStarred
* @param array $items
*/
private function setMultipleStarred(bool $isStarred, array $items)
{ {
foreach ($items as $item) { foreach ($items as $item) {
try { try {
$this->itemService->star( $this->oldItemService->star(
$item['feedId'], $item['feedId'],
$item['guidHash'], $item['guidHash'],
$isStarred, $isStarred,
@ -284,7 +291,7 @@ class ItemApiController extends ApiController
* @NoCSRFRequired * @NoCSRFRequired
* @CORS * @CORS
* *
* @param int[] $items item ids * @param array $items item ids
*/ */
public function unstarMultiple(array $items) public function unstarMultiple(array $items)
{ {

View File

@ -246,11 +246,11 @@ class FeedServiceV2 extends Service
/** /**
* Update a feed * Update a feed
* *
* @param Feed $feed Feed item * @param Feed|Entity $feed Feed item
* *
* @return Feed|Entity Database feed entity * @return Feed|Entity Database feed entity
*/ */
public function fetch(Feed $feed): Entity public function fetch(Entity $feed): Entity
{ {
if ($feed->getPreventUpdate() === true) { if ($feed->getPreventUpdate() === true) {
return $feed; return $feed;

View File

@ -101,4 +101,12 @@ class FolderServiceV2 extends Service
{ {
$this->mapper->purgeDeleted(); $this->mapper->purgeDeleted();
} }
public function rename(string $userId, int $folderId, string $newName)
{
/** @var Folder $folder */
$folder = $this->mapper->find($userId, $folderId);
$folder->setName($newName);
$this->mapper->update($folder);
}
} }

View File

@ -17,7 +17,9 @@ namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FeedApiController; use OCA\News\Controller\FeedApiController;
use OCA\News\Service\FeedService; use OCA\News\Service\FeedService;
use OCA\News\Service\FeedServiceV2;
use OCA\News\Service\ItemService; use OCA\News\Service\ItemService;
use OCA\News\Service\ItemServiceV2;
use OCA\News\Utility\PsrLogger; use OCA\News\Utility\PsrLogger;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
@ -34,18 +36,32 @@ use Psr\Log\LoggerInterface;
class FeedApiControllerTest extends TestCase class FeedApiControllerTest extends TestCase
{ {
/**
* @var \PHPUnit\Framework\MockObject\MockObject|FeedService
*/
private $oldFeedService;
/**
* @var \PHPUnit\Framework\MockObject\MockObject|FeedServiceV2
*/
private $feedService; private $feedService;
/**
* @var \PHPUnit\Framework\MockObject\MockObject|ItemService
*/
private $itemService; private $itemService;
private $feedAPI;
/**
* @var \PHPUnit\Framework\MockObject\MockObject|LoggerInterface
*/
private $logger;
private $class;
private $user; private $user;
private $msg; private $msg;
private $logger;
private $loggerParams;
protected function setUp(): void protected function setUp(): void
{ {
$this->loggerParams = ['hi'];
$this->logger = $this->getMockBuilder(LoggerInterface::class) $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -65,20 +81,23 @@ class FeedApiControllerTest extends TestCase
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getUID') ->method('getUID')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
$this->feedService = $this->getMockBuilder(FeedService::class) $this->oldFeedService = $this->getMockBuilder(FeedService::class)
->disableOriginalConstructor()
->getMock();
$this->feedService = $this->getMockBuilder(FeedServiceV2::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->itemService = $this->getMockBuilder(ItemService::class) $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->feedAPI = new FeedApiController( $this->class = new FeedApiController(
$appName, $appName,
$request, $request,
$userSession, $userSession,
$this->oldFeedService,
$this->feedService, $this->feedService,
$this->itemService, $this->itemService,
$this->logger, $this->logger
$this->loggerParams
); );
$this->msg = 'hohoho'; $this->msg = 'hohoho';
} }
@ -103,7 +122,7 @@ class FeedApiControllerTest extends TestCase
->with($this->equalTo($this->user->getUID())) ->with($this->equalTo($this->user->getUID()))
->will($this->returnValue($feeds)); ->will($this->returnValue($feeds));
$response = $this->feedAPI->index(); $response = $this->class->index();
$this->assertEquals( $this->assertEquals(
[ [
@ -133,7 +152,7 @@ class FeedApiControllerTest extends TestCase
->with($this->equalTo($this->user->getUID())) ->with($this->equalTo($this->user->getUID()))
->will($this->returnValue($feeds)); ->will($this->returnValue($feeds));
$response = $this->feedAPI->index(); $response = $this->class->index();
$this->assertEquals( $this->assertEquals(
[ [
@ -153,7 +172,7 @@ class FeedApiControllerTest extends TestCase
$this->equalTo(2) $this->equalTo(2)
); );
$this->feedAPI->delete(2); $this->class->delete(2);
} }
@ -167,7 +186,7 @@ class FeedApiControllerTest extends TestCase
) )
); );
$response = $this->feedAPI->delete(2); $response = $this->class->delete(2);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -180,21 +199,17 @@ class FeedApiControllerTest extends TestCase
$feeds = [new Feed()]; $feeds = [new Feed()];
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('create') ->method('create')
->with( ->with($this->user->getUID(), 'url', 3)
$this->equalTo('url'),
$this->equalTo(3),
$this->equalTo($this->user->getUID())
)
->will($this->returnValue($feeds[0])); ->will($this->returnValue($feeds[0]));
$this->itemService->expects($this->once()) $this->itemService->expects($this->once())
->method('getNewestItemId') ->method('getNewestItemId')
->will($this->returnValue(3)); ->will($this->returnValue(3));
$response = $this->feedAPI->create('url', 3); $response = $this->class->create('url', 3);
$this->assertEquals( $this->assertEquals(
[ [
@ -210,21 +225,17 @@ class FeedApiControllerTest extends TestCase
$feeds = [new Feed()]; $feeds = [new Feed()];
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('create') ->method('create')
->with( ->with($this->user->getUID(), 'ho', 3)
$this->equalTo('ho'),
$this->equalTo(3),
$this->equalTo($this->user->getUID())
)
->will($this->returnValue($feeds[0])); ->will($this->returnValue($feeds[0]));
$this->itemService->expects($this->once()) $this->itemService->expects($this->once())
->method('getNewestItemId') ->method('getNewestItemId')
->will($this->throwException(new ServiceNotFoundException(''))); ->will($this->throwException(new ServiceNotFoundException('')));
$response = $this->feedAPI->create('ho', 3); $response = $this->class->create('ho', 3);
$this->assertEquals( $this->assertEquals(
[ [
@ -238,15 +249,15 @@ class FeedApiControllerTest extends TestCase
public function testCreateExists() public function testCreateExists()
{ {
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('create') ->method('create')
->will( ->will(
$this->throwException(new ServiceConflictException($this->msg)) $this->throwException(new ServiceConflictException($this->msg))
); );
$response = $this->feedAPI->create('ho', 3); $response = $this->class->create('ho', 3);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -262,7 +273,7 @@ class FeedApiControllerTest extends TestCase
$this->throwException(new ServiceNotFoundException($this->msg)) $this->throwException(new ServiceNotFoundException($this->msg))
); );
$response = $this->feedAPI->create('ho', 3); $response = $this->class->create('ho', 3);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -280,13 +291,13 @@ class FeedApiControllerTest extends TestCase
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->feedAPI->read(3, 30); $this->class->read(3, 30);
} }
public function testMove() public function testMove()
{ {
$this->feedService->expects($this->once()) $this->oldFeedService->expects($this->once())
->method('patch') ->method('patch')
->with( ->with(
$this->equalTo(3), $this->equalTo(3),
@ -294,19 +305,19 @@ class FeedApiControllerTest extends TestCase
$this->equalTo(['folderId' => 30]) $this->equalTo(['folderId' => 30])
); );
$this->feedAPI->move(3, 30); $this->class->move(3, 30);
} }
public function testMoveDoesNotExist() public function testMoveDoesNotExist()
{ {
$this->feedService->expects($this->once()) $this->oldFeedService->expects($this->once())
->method('patch') ->method('patch')
->will( ->will(
$this->throwException(new ServiceNotFoundException($this->msg)) $this->throwException(new ServiceNotFoundException($this->msg))
); );
$response = $this->feedAPI->move(3, 4); $response = $this->class->move(3, 4);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -319,7 +330,7 @@ class FeedApiControllerTest extends TestCase
$feedId = 3; $feedId = 3;
$feedTitle = 'test'; $feedTitle = 'test';
$this->feedService->expects($this->once()) $this->oldFeedService->expects($this->once())
->method('patch') ->method('patch')
->with( ->with(
$this->equalTo($feedId), $this->equalTo($feedId),
@ -327,7 +338,7 @@ class FeedApiControllerTest extends TestCase
$this->equalTo(['title' => $feedTitle]) $this->equalTo(['title' => $feedTitle])
); );
$this->feedAPI->rename($feedId, $feedTitle); $this->class->rename($feedId, $feedTitle);
} }
@ -336,7 +347,7 @@ class FeedApiControllerTest extends TestCase
$feedId = 3; $feedId = 3;
$feedTitle = 'test'; $feedTitle = 'test';
$this->feedService->expects($this->once()) $this->oldFeedService->expects($this->once())
->method('patch') ->method('patch')
->with( ->with(
$this->equalTo($feedId), $this->equalTo($feedId),
@ -345,7 +356,7 @@ class FeedApiControllerTest extends TestCase
) )
->will($this->throwException(new ServiceNotFoundException('hi'))); ->will($this->throwException(new ServiceNotFoundException('hi')));
$result = $this->feedAPI->rename($feedId, $feedTitle); $result = $this->class->rename($feedId, $feedTitle);
$data = $result->getData(); $data = $result->getData();
$code = $result->getStatus(); $code = $result->getStatus();
@ -362,9 +373,9 @@ class FeedApiControllerTest extends TestCase
$feed->setUserId('john'); $feed->setUserId('john');
$feeds = [$feed]; $feeds = [$feed];
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('findAllFromAllUsers') ->method('findAll')
->will($this->returnValue($feeds)); ->will($this->returnValue($feeds));
$response = json_encode($this->feedAPI->fromAllUsers()); $response = json_encode($this->class->fromAllUsers());
$this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response); $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response);
} }
@ -373,12 +384,18 @@ class FeedApiControllerTest extends TestCase
{ {
$feedId = 3; $feedId = 3;
$userId = 'hi'; $userId = 'hi';
$feed = new Feed();
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('update') ->method('find')
->with($userId, $feedId); ->with($userId, $feedId)
->willReturn($feed);
$this->feedAPI->update($userId, $feedId); $this->feedService->expects($this->once())
->method('fetch')
->with($feed);
$this->class->update($userId, $feedId);
} }
@ -387,16 +404,14 @@ class FeedApiControllerTest extends TestCase
$feedId = 3; $feedId = 3;
$userId = 'hi'; $userId = 'hi';
$this->feedService->expects($this->once()) $this->feedService->expects($this->once())
->method('update') ->method('find')
->will($this->throwException(new \Exception($this->msg))); ->will($this->throwException(new \Exception($this->msg)));
$this->logger->expects($this->once()) $this->logger->expects($this->once())
->method('debug') ->method('debug')
->with('Could not update feed ' . $this->msg); ->with('Could not update feed ' . $this->msg);
$this->feedAPI->update($userId, $feedId); $this->class->update($userId, $feedId);
} }
} }

View File

@ -17,6 +17,7 @@ namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FolderApiController; use OCA\News\Controller\FolderApiController;
use OCA\News\Service\FolderService; use OCA\News\Service\FolderService;
use OCA\News\Service\FolderServiceV2;
use OCA\News\Service\ItemService; use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
@ -59,7 +60,7 @@ class FolderApiControllerTest extends TestCase
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getUID') ->method('getUID')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
$this->folderService = $this->getMockBuilder(FolderService::class) $this->folderService = $this->getMockBuilder(FolderServiceV2::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->itemService = $this->getMockBuilder(ItemService::class) $this->itemService = $this->getMockBuilder(ItemService::class)
@ -102,11 +103,11 @@ class FolderApiControllerTest extends TestCase
$folder->setName($folderName); $folder->setName($folderName);
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('create') ->method('create')
->with($this->equalTo($folderName), $this->equalTo($this->user->getUID())) ->with($this->user->getUID(), $folderName)
->will($this->returnValue($folder)); ->will($this->returnValue($folder));
$response = $this->folderAPI->create($folderName); $response = $this->folderAPI->create($folderName);
@ -124,8 +125,8 @@ class FolderApiControllerTest extends TestCase
$msg = 'exists'; $msg = 'exists';
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('create') ->method('create')
->will($this->throwException(new ServiceConflictException($msg))); ->will($this->throwException(new ServiceConflictException($msg)));
@ -143,8 +144,8 @@ class FolderApiControllerTest extends TestCase
$msg = 'exists'; $msg = 'exists';
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('purgeDeleted') ->method('purgeDeleted');
->with($this->equalTo($this->user->getUID()), $this->equalTo(false));
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('create') ->method('create')
->will($this->throwException(new ServiceValidationException($msg))); ->will($this->throwException(new ServiceValidationException($msg)));
@ -161,10 +162,9 @@ class FolderApiControllerTest extends TestCase
public function testDelete() public function testDelete()
{ {
$folderId = 23;
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('delete') ->method('delete')
->with($this->equalTo($folderId), $this->equalTo($this->user->getUID())); ->with($this->user->getUID(), 23);
$this->folderAPI->delete(23); $this->folderAPI->delete(23);
} }
@ -197,11 +197,7 @@ class FolderApiControllerTest extends TestCase
$this->folderService->expects($this->once()) $this->folderService->expects($this->once())
->method('rename') ->method('rename')
->with( ->with($this->user->getUID(), $folderId, $folderName);
$this->equalTo($folderId),
$this->equalTo($folderName),
$this->equalTo($this->user->getUID())
);
$this->folderAPI->update($folderId, $folderName); $this->folderAPI->update($folderId, $folderName);
} }

View File

@ -17,6 +17,7 @@ namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\ItemApiController; use OCA\News\Controller\ItemApiController;
use OCA\News\Service\ItemService; use OCA\News\Service\ItemService;
use OCA\News\Service\ItemServiceV2;
use \OCP\AppFramework\Http; use \OCP\AppFramework\Http;
use \OCA\News\Service\Exceptions\ServiceNotFoundException; use \OCA\News\Service\Exceptions\ServiceNotFoundException;
@ -32,8 +33,8 @@ class ItemApiControllerTest extends TestCase
{ {
private $itemService; private $itemService;
private $itemAPI; private $oldItemService;
private $api; private $class;
private $userSession; private $userSession;
private $user; private $user;
private $request; private $request;
@ -58,13 +59,17 @@ class ItemApiControllerTest extends TestCase
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getUID') ->method('getUID')
->will($this->returnValue('123')); ->will($this->returnValue('123'));
$this->itemService = $this->getMockBuilder(ItemService::class) $this->oldItemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->itemAPI = new ItemApiController( $this->itemService = $this->getMockBuilder(ItemServiceV2::class)
->disableOriginalConstructor()
->getMock();
$this->class = new ItemApiController(
$this->appName, $this->appName,
$this->request, $this->request,
$this->userSession, $this->userSession,
$this->oldItemService,
$this->itemService $this->itemService
); );
$this->msg = 'hi'; $this->msg = 'hi';
@ -79,7 +84,7 @@ class ItemApiControllerTest extends TestCase
$item->setGuidHash('guidhash'); $item->setGuidHash('guidhash');
$item->setFeedId(123); $item->setFeedId(123);
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('findAllItems') ->method('findAllItems')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -92,7 +97,7 @@ class ItemApiControllerTest extends TestCase
) )
->will($this->returnValue([$item])); ->will($this->returnValue([$item]));
$response = $this->itemAPI->index(1, 2, true, 30, 20, true); $response = $this->class->index(1, 2, true, 30, 20, true);
$this->assertEquals( $this->assertEquals(
[ [
@ -110,7 +115,7 @@ class ItemApiControllerTest extends TestCase
$item->setGuidHash('guidhash'); $item->setGuidHash('guidhash');
$item->setFeedId(123); $item->setFeedId(123);
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('findAllItems') ->method('findAllItems')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -123,7 +128,7 @@ class ItemApiControllerTest extends TestCase
) )
->will($this->returnValue([$item])); ->will($this->returnValue([$item]));
$response = $this->itemAPI->index(1, 2, false); $response = $this->class->index(1, 2, false);
$this->assertEquals( $this->assertEquals(
[ [
@ -141,7 +146,7 @@ class ItemApiControllerTest extends TestCase
$item->setGuidHash('guidhash'); $item->setGuidHash('guidhash');
$item->setFeedId(123); $item->setFeedId(123);
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('findAllNew') ->method('findAllNew')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -152,7 +157,7 @@ class ItemApiControllerTest extends TestCase
) )
->will($this->returnValue([$item])); ->will($this->returnValue([$item]));
$response = $this->itemAPI->updated(1, 2, 30); $response = $this->class->updated(1, 2, 30);
$this->assertEquals( $this->assertEquals(
[ [
@ -164,7 +169,7 @@ class ItemApiControllerTest extends TestCase
public function testRead() public function testRead()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('read') ->method('read')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -172,13 +177,13 @@ class ItemApiControllerTest extends TestCase
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->itemAPI->read(2); $this->class->read(2);
} }
public function testReadDoesNotExist() public function testReadDoesNotExist()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('read') ->method('read')
->will( ->will(
$this->throwException( $this->throwException(
@ -186,7 +191,7 @@ class ItemApiControllerTest extends TestCase
) )
); );
$response = $this->itemAPI->read(2); $response = $this->class->read(2);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -196,7 +201,7 @@ class ItemApiControllerTest extends TestCase
public function testUnread() public function testUnread()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('read') ->method('read')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -204,13 +209,13 @@ class ItemApiControllerTest extends TestCase
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->itemAPI->unread(2); $this->class->unread(2);
} }
public function testUnreadDoesNotExist() public function testUnreadDoesNotExist()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('read') ->method('read')
->will( ->will(
$this->throwException( $this->throwException(
@ -218,7 +223,7 @@ class ItemApiControllerTest extends TestCase
) )
); );
$response = $this->itemAPI->unread(2); $response = $this->class->unread(2);
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -228,7 +233,7 @@ class ItemApiControllerTest extends TestCase
public function testStar() public function testStar()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('star') ->method('star')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -237,13 +242,13 @@ class ItemApiControllerTest extends TestCase
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->itemAPI->star(2, 'hash'); $this->class->star(2, 'hash');
} }
public function testStarDoesNotExist() public function testStarDoesNotExist()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('star') ->method('star')
->will( ->will(
$this->throwException( $this->throwException(
@ -251,7 +256,7 @@ class ItemApiControllerTest extends TestCase
) )
); );
$response = $this->itemAPI->star(2, 'test'); $response = $this->class->star(2, 'test');
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -261,7 +266,7 @@ class ItemApiControllerTest extends TestCase
public function testUnstar() public function testUnstar()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('star') ->method('star')
->with( ->with(
$this->equalTo(2), $this->equalTo(2),
@ -270,13 +275,13 @@ class ItemApiControllerTest extends TestCase
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->itemAPI->unstar(2, 'hash'); $this->class->unstar(2, 'hash');
} }
public function testUnstarDoesNotExist() public function testUnstarDoesNotExist()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('star') ->method('star')
->will( ->will(
$this->throwException( $this->throwException(
@ -284,7 +289,7 @@ class ItemApiControllerTest extends TestCase
) )
); );
$response = $this->itemAPI->unstar(2, 'test'); $response = $this->class->unstar(2, 'test');
$data = $response->getData(); $data = $response->getData();
$this->assertEquals($this->msg, $data['message']); $this->assertEquals($this->msg, $data['message']);
@ -294,52 +299,52 @@ class ItemApiControllerTest extends TestCase
public function testReadAll() public function testReadAll()
{ {
$this->itemService->expects($this->once()) $this->oldItemService->expects($this->once())
->method('readAll') ->method('readAll')
->with( ->with(
$this->equalTo(30), $this->equalTo(30),
$this->equalTo($this->user->getUID()) $this->equalTo($this->user->getUID())
); );
$this->itemAPI->readAll(30); $this->class->readAll(30);
} }
public function testReadMultiple() public function testReadMultiple()
{ {
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('read') ->method('read')
->withConsecutive( ->withConsecutive(
[2, true, $this->user->getUID()], [2, true, $this->user->getUID()],
[4, true, $this->user->getUID()] [4, true, $this->user->getUID()]
); );
$this->itemAPI->readMultiple([2, 4]); $this->class->readMultiple([2, 4]);
} }
public function testReadMultipleDoesntCareAboutException() public function testReadMultipleDoesntCareAboutException()
{ {
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('read') ->method('read')
->withConsecutive( ->withConsecutive(
[2, true, $this->user->getUID()], [2, true, $this->user->getUID()],
[4, true, $this->user->getUID()] [4, true, $this->user->getUID()]
) )
->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null); ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null);
$this->itemAPI->readMultiple([2, 4]); $this->class->readMultiple([2, 4]);
} }
public function testUnreadMultiple() public function testUnreadMultiple()
{ {
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('read') ->method('read')
->withConsecutive( ->withConsecutive(
[2, false, $this->user->getUID()], [2, false, $this->user->getUID()],
[4, false, $this->user->getUID()] [4, false, $this->user->getUID()]
); );
$this->itemAPI->unreadMultiple([2, 4]); $this->class->unreadMultiple([2, 4]);
} }
@ -356,13 +361,13 @@ class ItemApiControllerTest extends TestCase
] ]
]; ];
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('star') ->method('star')
->withConsecutive( ->withConsecutive(
[2, 'a', true, $this->user->getUID()], [2, 'a', true, $this->user->getUID()],
[4, 'b', true, $this->user->getUID()] [4, 'b', true, $this->user->getUID()]
); );
$this->itemAPI->starMultiple($ids); $this->class->starMultiple($ids);
} }
@ -379,7 +384,7 @@ class ItemApiControllerTest extends TestCase
] ]
]; ];
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('star') ->method('star')
->withConsecutive( ->withConsecutive(
[2, 'a', true, $this->user->getUID()], [2, 'a', true, $this->user->getUID()],
@ -387,7 +392,7 @@ class ItemApiControllerTest extends TestCase
) )
->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null); ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null);
$this->itemAPI->starMultiple($ids); $this->class->starMultiple($ids);
} }
@ -404,14 +409,14 @@ class ItemApiControllerTest extends TestCase
] ]
]; ];
$this->itemService->expects($this->exactly(2)) $this->oldItemService->expects($this->exactly(2))
->method('star') ->method('star')
->withConsecutive( ->withConsecutive(
[2, 'a', false, $this->user->getUID()], [2, 'a', false, $this->user->getUID()],
[4, 'b', false, $this->user->getUID()] [4, 'b', false, $this->user->getUID()]
); );
$this->itemAPI->unstarMultiple($ids); $this->class->unstarMultiple($ids);
} }