diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-26 20:04:32 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-04-05 17:11:41 +0200 |
commit | 762002ec2eead8e282b671473a92c597a65b75e9 (patch) | |
tree | a15c4f5bef09f478cfc6a720f971c4e5f7f6dbdb /apps/provisioning_api | |
parent | c103aaaf255158a5f3a87967998fa7424405bcd7 (diff) | |
download | nextcloud-server-762002ec2eead8e282b671473a92c597a65b75e9.tar.gz nextcloud-server-762002ec2eead8e282b671473a92c597a65b75e9.zip |
Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/provisioning_api')
3 files changed, 54 insertions, 49 deletions
diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index 880f4987302..7c917fa6c98 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -76,15 +76,14 @@ class GroupsController extends OCSController { * @param ILogger $logger * @param UsersController $userController */ - public function __construct( - string $appName, - IRequest $request, - IUserManager $userManager, - IConfig $config, - IGroupManager $groupManager, - IUserSession $userSession, - AccountManager $accountManager, - ILogger $logger) { + public function __construct(string $appName, + IRequest $request, + IUserManager $userManager, + IConfig $config, + IGroupManager $groupManager, + IUserSession $userSession, + AccountManager $accountManager, + ILogger $logger) { parent::__construct($appName, $request); $this->groupManager = $groupManager; diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 9108e2e3312..44b440a40b2 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -26,61 +26,67 @@ namespace OCA\Provisioning_API\Tests\Controller; +use OC\Accounts\AccountManager; +use OC\Group\Manager; +use OC\SubAdmin; use OCA\Provisioning_API\Controller\GroupsController; -use OCP\IGroupManager; +use OCP\IConfig; use OCP\ILogger; use OCP\IRequest; use OCP\IUser; +use OCP\IUserManager; use OCP\IUserSession; class GroupsControllerTest extends \Test\TestCase { - /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */ + + /** @var IRequest|PHPUnit_Framework_MockObject_MockObject */ + protected $request; + /** @var IUserManager|PHPUnit_Framework_MockObject_MockObject */ + protected $userManager; + /** @var IConfig|PHPUnit_Framework_MockObject_MockObject */ + protected $config; + /** @var Manager|PHPUnit_Framework_MockObject_MockObject */ protected $groupManager; - /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|PHPUnit_Framework_MockObject_MockObject */ protected $userSession; - /** @var \OC\SubAdmin|\PHPUnit_Framework_MockObject_MockObject */ - protected $subAdminManager; - /** @var OCA\Provisioning_API\Controller\UsersController|\PHPUnit_Framework_MockObject_MockObject */ - protected $userController; + /** @var AccountManager|PHPUnit_Framework_MockObject_MockObject */ + protected $accountManager; + /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */ + protected $logger; - /** @var GroupsController */ + /** @var GroupsController|PHPUnit_Framework_MockObject_MockObject */ protected $api; protected function setUp() { parent::setUp(); - $this->subAdminManager = $this->getMockBuilder('OC\SubAdmin') - ->disableOriginalConstructor() - ->getMock(); + $this->request = $this->createMock(IRequest::class); + $this->userManager = $this->createMock(IUserManager::class); + $this->config = $this->createMock(IConfig::class); + $this->groupManager = $this->createMock(Manager::class); + $this->userSession = $this->createMock(IUserSession::class); + $this->accountManager = $this->createMock(AccountManager::class); + $this->logger = $this->createMock(ILogger::class); + + $this->subAdminManager = $this->createMock(SubAdmin::class); - $this->groupManager = $this->getMockBuilder('OC\Group\Manager') - ->disableOriginalConstructor() - ->getMock(); $this->groupManager - ->method('getSubAdmin') - ->willReturn($this->subAdminManager); - - $this->userSession = $this->getMockBuilder(IUserSession::class) - ->disableOriginalConstructor() - ->getMock(); - $request = $this->getMockBuilder(IRequest::class) - ->disableOriginalConstructor() + ->method('getSubAdmin') + ->willReturn($this->subAdminManager); + + $this->api = $this->getMockBuilder(GroupsController::class) + ->setConstructorArgs([ + 'provisioning_api', + $this->request, + $this->userManager, + $this->config, + $this->groupManager, + $this->userSession, + $this->accountManager, + $this->logger + ]) + ->setMethods(['fillStorageInfo']) ->getMock(); - - $logger = $this->createMock(ILogger::class); - - $this->userController = $this->getMockBuilder('OCA\Provisioning_API\Controller\UsersController') - ->disableOriginalConstructor() - ->getMock(); - - $this->api = new GroupsController( - 'provisioning_api', - $request, - $this->groupManager, - $this->userSession, - $logger, - $this->userController - ); } /** diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 0f53a7e6393..3d6ab8f3ebf 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -640,8 +640,8 @@ class UsersControllerTest extends TestCase { /** * @expectedException \OCP\AppFramework\OCS\OCSException - * @expectedExceptionCode 998 - * @expectedExceptionMessage The requested user could not be found + * @expectedExceptionCode 404 + * @expectedExceptionMessage User does not exist */ public function testGetUserTargetDoesNotExist() { $loggedInUser = $this->getMockBuilder(IUser::class) @@ -2818,7 +2818,7 @@ class UsersControllerTest extends TestCase { /** * @expectedException \OCP\AppFramework\OCS\OCSException - * @expectedExceptionCode 101 + * @expectedExceptionCode 404 * @expectedExceptionMessage User does not exist */ public function testGetUserSubAdminGroupsNotExistingTargetUser() { |