1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?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();
- }
- }
|