diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-07-24 07:44:09 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-07-24 11:42:07 +0200 |
commit | 6d4731024a18b7497dc19eefa97393eae7a3617b (patch) | |
tree | ef70dba744dcf8fa79574b07a7627771f1c7f62e /apps/provisioning_api | |
parent | 989614f9d5faa11157b232785537eb5cca927649 (diff) | |
download | nextcloud-server-6d4731024a18b7497dc19eefa97393eae7a3617b.tar.gz nextcloud-server-6d4731024a18b7497dc19eefa97393eae7a3617b.zip |
Some app fixes of phpstorm inspections
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/provisioning_api')
4 files changed, 22 insertions, 9 deletions
diff --git a/apps/provisioning_api/lib/Controller/AppsController.php b/apps/provisioning_api/lib/Controller/AppsController.php index 70316875762..d65b925cf7b 100644 --- a/apps/provisioning_api/lib/Controller/AppsController.php +++ b/apps/provisioning_api/lib/Controller/AppsController.php @@ -91,9 +91,9 @@ class AppsController extends OCSController { $info = \OCP\App::getAppInfo($app); if(!is_null($info)) { return new DataResponse(OC_App::getAppInfo($app)); - } else { - throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); } + + throw new OCSException('The request app was not found', \OCP\API::RESPOND_NOT_FOUND); } /** diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index 2d329bf974b..e167c07582f 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -30,6 +30,7 @@ use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCSController; use OCP\IGroup; use OCP\IGroupManager; +use OCP\ILogger; use OCP\IRequest; use OCP\IUserSession; use OCP\IUser; @@ -43,21 +44,27 @@ class GroupsController extends OCSController { /** @var IUserSession */ private $userSession; + /** @var ILogger */ + private $logger; + /** * @param string $appName * @param IRequest $request * @param IGroupManager $groupManager * @param IUserSession $userSession + * @param ILogger $logger */ public function __construct( $appName, IRequest $request, IGroupManager $groupManager, - IUserSession $userSession) { + IUserSession $userSession, + ILogger $logger) { parent::__construct($appName, $request); $this->groupManager = $groupManager; $this->userSession = $userSession; + $this->logger = $logger; } /** @@ -120,9 +127,9 @@ class GroupsController extends OCSController { }, $users); $users = array_values($users); return new DataResponse(['users' => $users]); - } else { - throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED); } + + throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED); } /** @@ -136,8 +143,8 @@ class GroupsController extends OCSController { */ public function addGroup($groupid) { // Validate name - if(empty($groupid)){ - \OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR); + if(empty($groupid)) { + $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); throw new OCSException('Invalid group name', 101); } // Check if it exists @@ -179,6 +186,7 @@ class GroupsController extends OCSController { throw new OCSException('Group does not exist', 101); } + /** @var IUser[] $subadmins */ $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); // New class returns IUser[] so convert back $uids = []; diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 25059e85425..caf6ae109f7 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -37,6 +37,7 @@ class GroupsControllerTest extends \Test\TestCase { protected $userSession; /** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */ protected $subAdminManager; + /** @var GroupsController */ protected $api; @@ -60,11 +61,15 @@ class GroupsControllerTest extends \Test\TestCase { $request = $this->getMockBuilder('OCP\IRequest') ->disableOriginalConstructor() ->getMock(); + + $logger = $this->createMock(ILogger::class); + $this->api = new GroupsController( 'provisioning_api', $request, $this->groupManager, - $this->userSession + $this->userSession, + $logger ); } diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index c712cd7485d..19b5fa65e9a 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1128,7 +1128,7 @@ class UsersControllerTest extends TestCase { } public function testEditUserAdminUserSelfEditChangeValidQuota() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock();; + $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') |