2015-01-07 09:34:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Joas Schilling <nickvergessen@owncloud.com>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2015-10-26 12:54:55 +00:00
|
|
|
* @author Roeland Jago Douma <rullzer@owncloud.com>
|
2016-01-12 14:02:16 +00:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-01-07 09:34:42 +00:00
|
|
|
*
|
2016-01-12 14:02:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2015-03-26 10:44:34 +00:00
|
|
|
* @license AGPL-3.0
|
2015-01-07 09:34:42 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00: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 09:34:42 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2015-01-07 09:34:42 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 10:44:34 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2015-01-07 09:34:42 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-01-07 09:34:42 +00:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
namespace OCA\Provisioning_API\Tests;
|
|
|
|
|
2015-11-20 10:27:11 +00:00
|
|
|
use OCP\IUser;
|
2015-08-11 10:51:00 +00:00
|
|
|
use OCP\IUserManager;
|
|
|
|
use OCP\IGroupManager;
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
abstract class TestCase extends \Test\TestCase {
|
2015-11-20 10:27:11 +00:00
|
|
|
|
|
|
|
/** @var IUser[] */
|
2015-01-07 09:34:42 +00:00
|
|
|
protected $users = array();
|
|
|
|
|
2015-08-11 10:51:00 +00:00
|
|
|
/** @var IUserManager */
|
|
|
|
protected $userManager;
|
|
|
|
|
|
|
|
/** @var IGroupManager */
|
|
|
|
protected $groupManager;
|
|
|
|
|
2015-01-07 09:34:42 +00:00
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
2015-07-25 20:37:14 +00:00
|
|
|
|
|
|
|
$this->userManager = \OC::$server->getUserManager();
|
|
|
|
$this->groupManager = \OC::$server->getGroupManager();
|
|
|
|
$this->groupManager->createGroup('admin');
|
2015-01-07 09:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a temp user
|
|
|
|
* @param int $num number of users to generate
|
2015-11-20 10:27:11 +00:00
|
|
|
* @return IUser[]|IUser
|
2015-01-07 09:34:42 +00:00
|
|
|
*/
|
|
|
|
protected function generateUsers($num = 1) {
|
|
|
|
$users = array();
|
|
|
|
for ($i = 0; $i < $num; $i++) {
|
2015-07-25 20:37:14 +00:00
|
|
|
$user = $this->userManager->createUser($this->getUniqueID(), 'password');
|
2015-01-07 09:34:42 +00:00
|
|
|
$this->users[] = $user;
|
|
|
|
$users[] = $user;
|
|
|
|
}
|
|
|
|
return count($users) == 1 ? reset($users) : $users;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function tearDown() {
|
|
|
|
foreach($this->users as $user) {
|
2015-07-25 20:37:14 +00:00
|
|
|
$user->delete();
|
2015-01-07 09:34:42 +00:00
|
|
|
}
|
|
|
|
|
2015-07-25 20:37:14 +00:00
|
|
|
$this->groupManager->get('admin')->delete();
|
2015-01-07 09:34:42 +00:00
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
}
|