Make scrutinizer happy

This commit is contained in:
Joas Schilling 2015-04-01 12:13:49 +02:00
parent efcc2e87ab
commit 730efe25a4
7 changed files with 16 additions and 23 deletions

View File

@ -60,7 +60,7 @@ class ActivityHelper {
$folders = $items = []; $folders = $items = [];
foreach ($favorites as $favorite) { foreach ($favorites as $favorite) {
$nodes = $rootFolder->getById($favorite); $nodes = $rootFolder->getById($favorite);
if ($nodes) { if (!empty($nodes)) {
/** @var \OCP\Files\Node $node */ /** @var \OCP\Files\Node $node */
$node = array_shift($nodes); $node = array_shift($nodes);
$path = substr($node->getPath(), strlen($user . '/files/')); $path = substr($node->getPath(), strlen($user . '/files/'));

View File

@ -95,7 +95,7 @@ class ActivityTest extends TestCase {
public function testTranslate() { public function testTranslate() {
$this->assertFalse( $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' 'Asserting that no translations are set for files_sharing'
); );
} }

View 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 $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 $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored * @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 * @return string
*/ */
public function getUserValue($userId, $appName, $key, $default = '') { public function getUserValue($userId, $appName, $key, $default = '') {

View File

@ -425,7 +425,7 @@ class Server extends SimpleContainer implements IServerContainer {
* currently being processed is returned from this method. * currently being processed is returned from this method.
* In case the current execution was not initiated by a web request null is returned * In case the current execution was not initiated by a web request null is returned
* *
* @return \OCP\IRequest|null * @return \OCP\IRequest
*/ */
function getRequest() { function getRequest() {
return $this->query('Request'); return $this->query('Request');

View 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 $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 $appName the appName that we stored the value under
* @param string $key the key under which the value is being stored * @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 * @return string
*/ */
public function getUserValue($userId, $appName, $key, $default = ''); public function getUserValue($userId, $appName, $key, $default = '');

View File

@ -59,7 +59,7 @@ interface IServerContainer {
* is returned from this method. * is returned from this method.
* In case the current execution was not initiated by a web request null is returned * In case the current execution was not initiated by a web request null is returned
* *
* @return \OCP\IRequest|null * @return \OCP\IRequest
*/ */
function getRequest(); function getRequest();

View File

@ -155,17 +155,7 @@ class Test_ActivityManager extends \Test\TestCase {
* @param array $users * @param array $users
*/ */
public function testGetUserFromTokenThrowInvalidToken($token, $users) { public function testGetUserFromTokenThrowInvalidToken($token, $users) {
if ($token !== null) { $this->mockRSSToken($token, $token, $users);
$this->request->expects($this->any())
->method('getParam')
->with('token', '')
->willReturn($token);
}
$this->config->expects($this->any())
->method('getUsersForUserValue')
->with('activity', 'rsstoken', $token)
->willReturn($users);
\Test_Helper::invokePrivate($this->activityManager, 'getUserFromToken'); \Test_Helper::invokePrivate($this->activityManager, 'getUserFromToken');
} }
@ -188,20 +178,23 @@ class Test_ActivityManager extends \Test\TestCase {
if ($userLoggedIn !== null) { if ($userLoggedIn !== null) {
$this->mockUserSession($userLoggedIn); $this->mockUserSession($userLoggedIn);
} }
$this->mockRSSToken($token, '123456789012345678901234567890', ['user1']);
if ($token !== null) { $this->assertEquals($expected, $this->activityManager->getCurrentUserId());
}
protected function mockRSSToken($requestToken, $userToken, $users) {
if ($requestToken !== null) {
$this->request->expects($this->any()) $this->request->expects($this->any())
->method('getParam') ->method('getParam')
->with('token', '') ->with('token', '')
->willReturn($token); ->willReturn($requestToken);
} }
$this->config->expects($this->any()) $this->config->expects($this->any())
->method('getUsersForUserValue') ->method('getUsersForUserValue')
->with('activity', 'rsstoken', '123456789012345678901234567890') ->with('activity', 'rsstoken', $userToken)
->willReturn(['user1']); ->willReturn($users);
$this->assertEquals($expected, $this->activityManager->getCurrentUserId());
} }
protected function mockUserSession($user) { protected function mockUserSession($user) {