UserTrait.php 767 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Traits;
  9. /**
  10. * Allow creating users in a temporary backend
  11. */
  12. trait UserTrait {
  13. /**
  14. * @var \Test\Util\User\Dummy|\OCP\UserInterface
  15. */
  16. protected $userBackend;
  17. protected function createUser($name, $password) {
  18. $this->userBackend->createUser($name, $password);
  19. }
  20. protected function setUpUserTrait() {
  21. $this->userBackend = new \Test\Util\User\Dummy();
  22. \OC::$server->getUserManager()->registerBackend($this->userBackend);
  23. }
  24. protected function tearDownUserTrait() {
  25. \OC::$server->getUserManager()->removeBackend($this->userBackend);
  26. }
  27. }