12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace OCA\Provisioning_API\Tests;
- use OCP\IGroupManager;
- use OCP\IUser;
- use OCP\IUserManager;
- abstract class TestCase extends \Test\TestCase {
-
- protected $users = [];
-
- protected $userManager;
-
- protected $groupManager;
- protected function setUp(): void {
- parent::setUp();
- $this->userManager = \OC::$server->getUserManager();
- $this->groupManager = \OC::$server->getGroupManager();
- $this->groupManager->createGroup('admin');
- }
-
- 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();
- }
- }
|