2015-01-07 12:34:42 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-01-07 12:34:42 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* @license AGPL-3.0
|
2015-01-07 12:34:42 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2015-01-07 12:34:42 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2015-01-07 12:34:42 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 13:44:34 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2015-01-07 12:34:42 +03:00
|
|
|
*
|
2015-03-26 13:44:34 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-01-07 12:34:42 +03:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 13:37:37 +03:00
|
|
|
|
2015-01-07 12:34:42 +03:00
|
|
|
namespace OCA\Provisioning_API\Tests;
|
|
|
|
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCP\IGroupManager;
|
2015-11-20 13:27:11 +03:00
|
|
|
use OCP\IUser;
|
2015-08-11 13:51:00 +03:00
|
|
|
use OCP\IUserManager;
|
|
|
|
|
2015-01-07 12:34:42 +03:00
|
|
|
abstract class TestCase extends \Test\TestCase {
|
2015-11-20 13:27:11 +03:00
|
|
|
|
|
|
|
/** @var IUser[] */
|
2020-03-26 11:30:18 +03:00
|
|
|
protected $users = [];
|
2015-01-07 12:34:42 +03:00
|
|
|
|
2015-08-11 13:51:00 +03:00
|
|
|
/** @var IUserManager */
|
|
|
|
protected $userManager;
|
|
|
|
|
|
|
|
/** @var IGroupManager */
|
|
|
|
protected $groupManager;
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function setUp(): void {
|
2015-01-07 12:34:42 +03:00
|
|
|
parent::setUp();
|
2015-07-25 23:37:14 +03:00
|
|
|
|
|
|
|
$this->userManager = \OC::$server->getUserManager();
|
|
|
|
$this->groupManager = \OC::$server->getGroupManager();
|
|
|
|
$this->groupManager->createGroup('admin');
|
2015-01-07 12:34:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a temp user
|
|
|
|
* @param int $num number of users to generate
|
2015-11-20 13:27:11 +03:00
|
|
|
* @return IUser[]|IUser
|
2015-01-07 12:34:42 +03:00
|
|
|
*/
|
|
|
|
protected function generateUsers($num = 1) {
|
2020-03-26 11:30:18 +03:00
|
|
|
$users = [];
|
2015-01-07 12:34:42 +03:00
|
|
|
for ($i = 0; $i < $num; $i++) {
|
2015-07-25 23:37:14 +03:00
|
|
|
$user = $this->userManager->createUser($this->getUniqueID(), 'password');
|
2015-01-07 12:34:42 +03:00
|
|
|
$this->users[] = $user;
|
|
|
|
$users[] = $user;
|
|
|
|
}
|
|
|
|
return count($users) == 1 ? reset($users) : $users;
|
|
|
|
}
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function tearDown(): void {
|
2015-01-07 12:34:42 +03:00
|
|
|
foreach($this->users as $user) {
|
2015-07-25 23:37:14 +03:00
|
|
|
$user->delete();
|
2015-01-07 12:34:42 +03:00
|
|
|
}
|
|
|
|
|
2015-07-25 23:37:14 +03:00
|
|
|
$this->groupManager->get('admin')->delete();
|
2015-01-07 12:34:42 +03:00
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
}
|