]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make scrutinizer happy
authorJoas Schilling <nickvergessen@owncloud.com>
Wed, 1 Apr 2015 10:13:49 +0000 (12:13 +0200)
committerJoas Schilling <nickvergessen@owncloud.com>
Wed, 1 Apr 2015 10:13:49 +0000 (12:13 +0200)
apps/files/lib/activityhelper.php
apps/files/tests/activitytest.php
lib/private/allconfig.php
lib/private/server.php
lib/public/iconfig.php
lib/public/iservercontainer.php
tests/lib/activitymanager.php

index e05ae6c9831ccd6a0e32d93a6bc4959ac1cf30be..f9ff722b1c239b35164f69389ddc8f3b2a6d51b2 100644 (file)
@@ -60,7 +60,7 @@ class ActivityHelper {
                $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/'));
index b8766f9522451ed31b430e656383f7c649ee4fee..1f8d6330e51e2bbb532b63f36335b488beeb13ff 100644 (file)
@@ -95,7 +95,7 @@ class ActivityTest extends TestCase {
 
        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'
                );
        }
index df75a332a1305c5e4b85133b9cd1dab65e5bfa52..63cc92601bb4a3cbfb30fc8e16889ae682fa65a9 100644 (file)
@@ -253,7 +253,7 @@ class AllConfig implements \OCP\IConfig {
         * @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 = '') {
index 6b212ee94a44f6c50b852dd3e47442fcabd29e01..02d649585d63dabb058125e6e21686b1564a89da 100644 (file)
@@ -425,7 +425,7 @@ class Server extends SimpleContainer implements IServerContainer {
         * 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');
index c63ba1a90a6d2d1f30d8626ca4a77e8f324a7914..f28a114a2bb6a43d0f57894075dfe29c318fe9f0 100644 (file)
@@ -133,7 +133,7 @@ interface IConfig {
         * @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 = '');
index d7df884adf88062891d47ba95268accc6e79970f..f11a5c0133f782727959da6f96a3ced756f1640c 100644 (file)
@@ -59,7 +59,7 @@ interface IServerContainer {
         * 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();
 
index 51ab4a7a947fed674180a7bae7d2b74d3d2dc19c..d3263fa2ede90938031cfc6a45c203f688f26f57 100644 (file)
@@ -155,17 +155,7 @@ class Test_ActivityManager extends \Test\TestCase {
         * @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');
        }
 
@@ -188,20 +178,23 @@ class Test_ActivityManager extends \Test\TestCase {
                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) {