summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-08 13:28:19 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-08 13:28:19 -0700
commit24e99016a924b296685abc290f12d9f533f684d5 (patch)
tree7d706f9764145981511bb1c2113da3b1ce1efc01 /tests
parent76bdd6bc81bea48ba07d0cdd2a2496a911b914c7 (diff)
parent176c2f150299e9ddc335158b27f4a61e45ef80ac (diff)
downloadnextcloud-server-24e99016a924b296685abc290f12d9f533f684d5.tar.gz
nextcloud-server-24e99016a924b296685abc290f12d9f533f684d5.zip
Merge pull request #5188 from owncloud/master-delete-user
User::delete should return bool
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/user.php52
1 files changed, 41 insertions, 11 deletions
diff --git a/tests/lib/user.php b/tests/lib/user.php
index 66c7f3f0d74..fdf9e7a08e0 100644
--- a/tests/lib/user.php
+++ b/tests/lib/user.php
@@ -12,18 +12,26 @@ namespace Test;
use OC\Hooks\PublicEmitter;
class User extends \PHPUnit_Framework_TestCase {
-
+ /**
+ * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
+ */
+ private $backend;
+
+ protected function setUp(){
+ $this->backend = $this->getMock('\OC_User_Dummy');
+ $manager = \OC_User::getManager();
+ $manager->registerBackend($this->backend);
+ }
+
public function testCheckPassword() {
- /**
- * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
- */
- $backend = $this->getMock('\OC_User_Dummy');
- $backend->expects($this->once())
+
+ $this->backend->expects($this->once())
->method('checkPassword')
->with($this->equalTo('foo'), $this->equalTo('bar'))
- ->will($this->returnValue('foo'));
+ ->will($this->returnValue('foo'))
+ ;
- $backend->expects($this->any())
+ $this->backend->expects($this->any())
->method('implementsActions')
->will($this->returnCallback(function ($actions) {
if ($actions === \OC_USER_BACKEND_CHECK_PASSWORD) {
@@ -33,11 +41,33 @@ class User extends \PHPUnit_Framework_TestCase {
}
}));
- $manager = \OC_User::getManager();
- $manager->registerBackend($backend);
-
$uid = \OC_User::checkPassword('foo', 'bar');
$this->assertEquals($uid, 'foo');
}
+
+ public function testDeleteUser() {
+ $fail = \OC_User::deleteUser('victim');
+ $this->assertFalse($fail);
+
+ $success = \OC_User::createUser('victim', 'password');
+
+ $success = \OC_User::deleteUser('victim');
+ $this->assertTrue($success);
+ }
+
+ public function testCreateUser(){
+ $this->backend->expects($this->any())
+ ->method('implementsActions')
+ ->will($this->returnCallback(function ($actions) {
+ if ($actions === \OC_USER_BACKEND_CREATE_USER) {
+ return true;
+ } else {
+ return false;
+ }
+ }));
+
+ $user = \OC_User::createUser('newuser', 'newpassword');
+ $this->assertEquals('newuser', $user->getUid());
+ }
} \ No newline at end of file