UserTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. }