mirror of
https://github.com/nextcloud/server.git
synced 2024-12-29 00:18:42 +00:00
afa48a4e0e
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?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();
|
|
}
|
|
}
|