$folders = $items = [];
foreach ($favorites as $favorite) {
$nodes = $rootFolder->getById($favorite);
- if ($nodes) {
+ if (!empty($nodes)) {
/** @var \OCP\Files\Node $node */
$node = array_shift($nodes);
$path = substr($node->getPath(), strlen($user . '/files/'));
public function testTranslate() {
$this->assertFalse(
- $this->activityExtension->translate('files_sharing', '', '', array(), false, false, 'en'),
+ $this->activityExtension->translate('files_sharing', '', [], false, false, 'en'),
'Asserting that no translations are set for files_sharing'
);
}
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
- * @param string $default the default value to be returned if the value isn't set
+ * @param mixed $default the default value to be returned if the value isn't set
* @return string
*/
public function getUserValue($userId, $appName, $key, $default = '') {
* currently being processed is returned from this method.
* In case the current execution was not initiated by a web request null is returned
*
- * @return \OCP\IRequest|null
+ * @return \OCP\IRequest
*/
function getRequest() {
return $this->query('Request');
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored
- * @param string $default the default value to be returned if the value isn't set
+ * @param mixed $default the default value to be returned if the value isn't set
* @return string
*/
public function getUserValue($userId, $appName, $key, $default = '');
* is returned from this method.
* In case the current execution was not initiated by a web request null is returned
*
- * @return \OCP\IRequest|null
+ * @return \OCP\IRequest
*/
function getRequest();
* @param array $users
*/
public function testGetUserFromTokenThrowInvalidToken($token, $users) {
- if ($token !== null) {
- $this->request->expects($this->any())
- ->method('getParam')
- ->with('token', '')
- ->willReturn($token);
- }
- $this->config->expects($this->any())
- ->method('getUsersForUserValue')
- ->with('activity', 'rsstoken', $token)
- ->willReturn($users);
-
+ $this->mockRSSToken($token, $token, $users);
\Test_Helper::invokePrivate($this->activityManager, 'getUserFromToken');
}
if ($userLoggedIn !== null) {
$this->mockUserSession($userLoggedIn);
}
+ $this->mockRSSToken($token, '123456789012345678901234567890', ['user1']);
+
+ $this->assertEquals($expected, $this->activityManager->getCurrentUserId());
+ }
- if ($token !== null) {
+ protected function mockRSSToken($requestToken, $userToken, $users) {
+ if ($requestToken !== null) {
$this->request->expects($this->any())
->method('getParam')
->with('token', '')
- ->willReturn($token);
+ ->willReturn($requestToken);
}
$this->config->expects($this->any())
->method('getUsersForUserValue')
- ->with('activity', 'rsstoken', '123456789012345678901234567890')
- ->willReturn(['user1']);
-
- $this->assertEquals($expected, $this->activityManager->getCurrentUserId());
+ ->with('activity', 'rsstoken', $userToken)
+ ->willReturn($users);
}
protected function mockUserSession($user) {