namespace OCA\Provisioning_API\Tests\Controller;
use OC\Group\Manager;
-use OC\SubAdmin;
use OC\User\NoUserException;
use OCA\Provisioning_API\Controller\GroupsController;
use OCP\Accounts\IAccountManager;
+use OCP\Group\ISubAdmin;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
protected $userSession;
/** @var IAccountManager|\PHPUnit\Framework\MockObject\MockObject */
protected $accountManager;
+ /** @var ISubAdmin|\PHPUnit\Framework\MockObject\MockObject */
+ protected $subAdminManager;
/** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */
protected $l10nFactory;
/** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
- /** @var SubAdmin|\PHPUnit\Framework\MockObject\MockObject */
- protected $subAdminManager;
/** @var GroupsController|\PHPUnit\Framework\MockObject\MockObject */
protected $api;
$this->groupManager = $this->createMock(Manager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->accountManager = $this->createMock(IAccountManager::class);
+ $this->subAdminManager = $this->createMock(ISubAdmin::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->logger = $this->createMock(LoggerInterface::class);
- $this->subAdminManager = $this->createMock(SubAdmin::class);
-
$this->groupManager
->method('getSubAdmin')
->willReturn($this->subAdminManager);
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->subAdminManager,
$this->l10nFactory,
$this->logger
])
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Group\ISubAdmin;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IL10N;
protected $api;
/** @var IAccountManager|MockObject */
protected $accountManager;
+ /** @var ISubAdmin|MockObject */
+ protected $subAdminManager;
/** @var IURLGenerator|MockObject */
protected $urlGenerator;
/** @var IRequest|MockObject */
$this->logger = $this->createMock(LoggerInterface::class);
$this->request = $this->createMock(IRequest::class);
$this->accountManager = $this->createMock(IAccountManager::class);
+ $this->subAdminManager = $this->createMock(ISubAdmin::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->l10nFactory = $this->createMock(IFactory::class);
$this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->subAdminManager,
$this->l10nFactory,
$this->urlGenerator,
$this->logger,
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->subAdminManager,
$this->l10nFactory,
$this->urlGenerator,
$this->logger,
->disableOriginalConstructor()
->getMock();
$loggedInUser
- ->expects($this->exactly(2))
->method('getUID')
->willReturn('admin');
$targetUser = $this->getMockBuilder(IUser::class)
->method('getSystemEMailAddress')
->willReturn('demo@nextcloud.com');
$this->userSession
- ->expects($this->once())
->method('getUser')
->willReturn($loggedInUser);
$this->userManager
- ->expects($this->exactly(2))
->method('get')
->with('UID')
->willReturn($targetUser);
$this->groupManager
- ->expects($this->once())
->method('isAdmin')
->with('admin')
->willReturn(true);
->disableOriginalConstructor()
->getMock();
$loggedInUser
- ->expects($this->exactly(2))
->method('getUID')
->willReturn('subadmin');
$targetUser = $this->getMockBuilder(IUser::class)
->method('getSystemEMailAddress')
->willReturn('demo@nextcloud.com');
$this->userSession
- ->expects($this->once())
->method('getUser')
->willReturn($loggedInUser);
$this->userManager
- ->expects($this->exactly(2))
->method('get')
->with('UID')
->willReturn($targetUser);
$this->groupManager
- ->expects($this->once())
->method('isAdmin')
->with('subadmin')
->willReturn(false);
->disableOriginalConstructor()
->getMock();
$loggedInUser
- ->expects($this->exactly(3))
->method('getUID')
->willReturn('UID');
$targetUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$this->userSession
- ->expects($this->once())
->method('getUser')
->willReturn($loggedInUser);
$this->userManager
- ->expects($this->exactly(2))
->method('get')
->with('UID')
->willReturn($targetUser);
$this->groupManager
- ->expects($this->once())
->method('isAdmin')
->with('UID')
->willReturn(false);
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->subAdminManager,
$this->l10nFactory,
$this->urlGenerator,
$this->logger,
$this->groupManager,
$this->userSession,
$this->accountManager,
+ $this->subAdminManager,
$this->l10nFactory,
$this->urlGenerator,
$this->logger,