testcase.php 1.86 KB
Newer Older
1
2
<?php
/**
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
3
4
 * @author Joas Schilling <nickvergessen@owncloud.com>
 * @author Morris Jobke <hey@morrisjobke.de>
5
 * @author Roeland Jago Douma <roeland@famdouma.nl>
6
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
7
8
 * @copyright Copyright (c) 2015, ownCloud, Inc.
 * @license AGPL-3.0
9
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
10
11
12
 * 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.
13
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
16
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
18
 *
Jenkins for ownCloud's avatar
Jenkins for ownCloud committed
19
20
 * 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/>
21
22
 *
 */
23

24
25
namespace OCA\Provisioning_API\Tests;

Roeland Jago Douma's avatar
Roeland Jago Douma committed
26
27
28
use OCP\IUserManager;
use OCP\IGroupManager;

29
30
31
abstract class TestCase extends \Test\TestCase {
	protected $users = array();

Roeland Jago Douma's avatar
Roeland Jago Douma committed
32
33
34
35
36
37
	/** @var IUserManager */
	protected $userManager;

	/** @var IGroupManager */
	protected $groupManager;

38
39
	protected function setUp() {
		parent::setUp();
40
41
42
43

		$this->userManager = \OC::$server->getUserManager();
		$this->groupManager = \OC::$server->getGroupManager();
		$this->groupManager->createGroup('admin');
44
45
46
47
48
	}

	/**
	 * Generates a temp user
	 * @param int $num number of users to generate
Roeland Jago Douma's avatar
Roeland Jago Douma committed
49
	 * @return IUser[]|Iuser
50
51
52
53
	 */
	protected function generateUsers($num = 1) {
		$users = array();
		for ($i = 0; $i < $num; $i++) {
54
			$user = $this->userManager->createUser($this->getUniqueID(), 'password');
55
56
57
58
59
60
61
62
			$this->users[] = $user;
			$users[] = $user;
		}
		return count($users) == 1 ? reset($users) : $users;
	}

	protected function tearDown() {
		foreach($this->users as $user) {
63
			$user->delete();
64
65
		}

66
		$this->groupManager->get('admin')->delete();
67
68
69
		parent::tearDown();
	}
}