aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests/TestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/provisioning_api/tests/TestCase.php')
-rw-r--r--apps/provisioning_api/tests/TestCase.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/provisioning_api/tests/TestCase.php b/apps/provisioning_api/tests/TestCase.php
new file mode 100644
index 00000000000..30e7f3a4ecf
--- /dev/null
+++ b/apps/provisioning_api/tests/TestCase.php
@@ -0,0 +1,57 @@
+<?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;
+use OCP\Server;
+
+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 = Server::get(IUserManager::class);
+ $this->groupManager = Server::get(IGroupManager::class);
+ $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();
+ }
+}