Fixed tests

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-03-26 20:04:32 +02:00
parent c103aaaf25
commit 762002ec2e
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
5 changed files with 58 additions and 53 deletions

View File

@ -76,15 +76,14 @@ class GroupsController extends OCSController {
* @param ILogger $logger * @param ILogger $logger
* @param UsersController $userController * @param UsersController $userController
*/ */
public function __construct( public function __construct(string $appName,
string $appName, IRequest $request,
IRequest $request, IUserManager $userManager,
IUserManager $userManager, IConfig $config,
IConfig $config, IGroupManager $groupManager,
IGroupManager $groupManager, IUserSession $userSession,
IUserSession $userSession, AccountManager $accountManager,
AccountManager $accountManager, ILogger $logger) {
ILogger $logger) {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->groupManager = $groupManager; $this->groupManager = $groupManager;

View File

@ -26,61 +26,67 @@
namespace OCA\Provisioning_API\Tests\Controller; namespace OCA\Provisioning_API\Tests\Controller;
use OC\Accounts\AccountManager;
use OC\Group\Manager;
use OC\SubAdmin;
use OCA\Provisioning_API\Controller\GroupsController; use OCA\Provisioning_API\Controller\GroupsController;
use OCP\IGroupManager; use OCP\IConfig;
use OCP\ILogger; use OCP\ILogger;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
class GroupsControllerTest extends \Test\TestCase { class GroupsControllerTest extends \Test\TestCase {
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager;
/** @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 GroupsController */ /** @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 */
protected $userSession;
/** @var AccountManager|PHPUnit_Framework_MockObject_MockObject */
protected $accountManager;
/** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
protected $logger;
/** @var GroupsController|PHPUnit_Framework_MockObject_MockObject */
protected $api; protected $api;
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->subAdminManager = $this->getMockBuilder('OC\SubAdmin') $this->request = $this->createMock(IRequest::class);
->disableOriginalConstructor() $this->userManager = $this->createMock(IUserManager::class);
->getMock(); $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 $this->groupManager
->method('getSubAdmin') ->method('getSubAdmin')
->willReturn($this->subAdminManager); ->willReturn($this->subAdminManager);
$this->userSession = $this->getMockBuilder(IUserSession::class) $this->api = $this->getMockBuilder(GroupsController::class)
->disableOriginalConstructor() ->setConstructorArgs([
'provisioning_api',
$this->request,
$this->userManager,
$this->config,
$this->groupManager,
$this->userSession,
$this->accountManager,
$this->logger
])
->setMethods(['fillStorageInfo'])
->getMock(); ->getMock();
$request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->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
);
} }
/** /**

View File

@ -640,8 +640,8 @@ class UsersControllerTest extends TestCase {
/** /**
* @expectedException \OCP\AppFramework\OCS\OCSException * @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 998 * @expectedExceptionCode 404
* @expectedExceptionMessage The requested user could not be found * @expectedExceptionMessage User does not exist
*/ */
public function testGetUserTargetDoesNotExist() { public function testGetUserTargetDoesNotExist() {
$loggedInUser = $this->getMockBuilder(IUser::class) $loggedInUser = $this->getMockBuilder(IUser::class)
@ -2818,7 +2818,7 @@ class UsersControllerTest extends TestCase {
/** /**
* @expectedException \OCP\AppFramework\OCS\OCSException * @expectedException \OCP\AppFramework\OCS\OCSException
* @expectedExceptionCode 101 * @expectedExceptionCode 404
* @expectedExceptionMessage User does not exist * @expectedExceptionMessage User does not exist
*/ */
public function testGetUserSubAdminGroupsNotExistingTargetUser() { public function testGetUserSubAdminGroupsNotExistingTargetUser() {

0
build/autoloaderchecker.sh Normal file → Executable file
View File

View File

@ -5,7 +5,7 @@ Feature: provisioning
Scenario: Getting an not existing user Scenario: Getting an not existing user
Given As an "admin" Given As an "admin"
When sending "GET" to "/cloud/users/test" When sending "GET" to "/cloud/users/test"
Then the OCS status code should be "998" Then the OCS status code should be "404"
And the HTTP status code should be "200" And the HTTP status code should be "200"
Scenario: Listing all users Scenario: Listing all users
@ -264,7 +264,7 @@ Feature: provisioning
And user "not-user" does not exist And user "not-user" does not exist
And group "new-group" exists And group "new-group" exists
When sending "GET" to "/cloud/users/not-user/subadmins" When sending "GET" to "/cloud/users/not-user/subadmins"
Then the OCS status code should be "101" Then the OCS status code should be "404"
And the HTTP status code should be "200" And the HTTP status code should be "200"
Scenario: Getting subadmin users of a group Scenario: Getting subadmin users of a group