You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
  1. <?php
  2. /**
  3. * Copyright (c) 2013 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;
  9. /**
  10. * Class User
  11. *
  12. * @group DB
  13. *
  14. * @package Test
  15. */
  16. class UserTest extends TestCase {
  17. /**
  18. * @var \OC\User\Backend | \PHPUnit_Framework_MockObject_MockObject $backend
  19. */
  20. private $backend;
  21. protected function setUp(){
  22. parent::setUp();
  23. $this->backend = $this->getMock('\Test\Util\User\Dummy');
  24. $manager = \OC::$server->getUserManager();
  25. $manager->registerBackend($this->backend);
  26. }
  27. public function testCheckPassword() {
  28. $this->backend->expects($this->once())
  29. ->method('checkPassword')
  30. ->with($this->equalTo('foo'), $this->equalTo('bar'))
  31. ->will($this->returnValue('foo'))
  32. ;
  33. $this->backend->expects($this->any())
  34. ->method('implementsActions')
  35. ->will($this->returnCallback(function ($actions) {
  36. if ($actions === \OC_USER_BACKEND_CHECK_PASSWORD) {
  37. return true;
  38. } else {
  39. return false;
  40. }
  41. }));
  42. $uid = \OC_User::checkPassword('foo', 'bar');
  43. $this->assertEquals($uid, 'foo');
  44. }
  45. }