server/apps/provisioning_api/tests/testcase.php

74 lines
1.9 KiB
PHP
Raw Normal View History

<?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>
*
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-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-03-26 10:44:34 +00:00
* This program is distributed in the hope that it will be useful,
* 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-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/>
*
*/
namespace OCA\Provisioning_API\Tests;
use OCP\IUser;
2015-08-11 10:51:00 +00:00
use OCP\IUserManager;
use OCP\IGroupManager;
abstract class TestCase extends \Test\TestCase {
/** @var IUser[] */
protected $users = array();
2015-08-11 10:51:00 +00:00
/** @var IUserManager */
protected $userManager;
/** @var IGroupManager */
protected $groupManager;
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');
}
/**
* Generates a temp user
* @param int $num number of users to generate
* @return IUser[]|IUser
*/
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');
$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-07-25 20:37:14 +00:00
$this->groupManager->get('admin')->delete();
parent::tearDown();
}
}