1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
- * SPDX-License-Identifier: AGPL-3.0-only
- */
- namespace OCA\Provisioning_API\Tests;
- use OCP\IGroupManager;
- use OCP\IUser;
- use OCP\IUserManager;
- abstract class TestCase extends \Test\TestCase {
- /** @var IUser[] */
- protected $users = [];
- /** @var IUserManager */
- protected $userManager;
- /** @var IGroupManager */
- protected $groupManager;
- protected function setUp(): void {
- parent::setUp();
- $this->userManager = \OC::$server->getUserManager();
- $this->groupManager = \OC::$server->getGroupManager();
- $this->groupManager->createGroup('admin');
- }
- /**
- * Generates a temp user
- * @param int $num number of users to generate
- * @return IUser[]|IUser
- */
- protected function generateUsers($num = 1) {
- $users = [];
- for ($i = 0; $i < $num; $i++) {
- $user = $this->userManager->createUser($this->getUniqueID(), 'password');
- $this->users[] = $user;
- $users[] = $user;
- }
- return count($users) == 1 ? reset($users) : $users;
- }
- protected function tearDown(): void {
- foreach ($this->users as $user) {
- $user->delete();
- }
- $this->groupManager->get('admin')->delete();
- parent::tearDown();
- }
- }
|