summaryrefslogtreecommitdiffstats
path: root/tests/lib/user
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-11-05 12:21:02 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-11-06 17:36:35 +0100
commit216ef617db7b0ed6e717fe92867aa11245a4cece (patch)
treefb0fe7caa652bbcc4c3a5f83f071be643c00af9b /tests/lib/user
parent62047f86f5828a5743a476177318bc00ca8e453f (diff)
downloadnextcloud-server-216ef617db7b0ed6e717fe92867aa11245a4cece.tar.gz
nextcloud-server-216ef617db7b0ed6e717fe92867aa11245a4cece.zip
Do not use uniqid in Group and User tests as it is not unique on windows
Diffstat (limited to 'tests/lib/user')
-rw-r--r--tests/lib/user/backend.php21
-rw-r--r--tests/lib/user/database.php13
-rw-r--r--tests/lib/user/dummy.php3
3 files changed, 21 insertions, 16 deletions
diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php
index 0d3914c7ca6..c2040f4e3be 100644
--- a/tests/lib/user/backend.php
+++ b/tests/lib/user/backend.php
@@ -30,7 +30,7 @@
* For an example see /tests/lib/user/dummy.php
*/
-abstract class Test_User_Backend extends PHPUnit_Framework_TestCase {
+abstract class Test_User_Backend extends \Test\TestCase {
/**
* @var OC_User_Backend $backend
*/
@@ -42,7 +42,7 @@ abstract class Test_User_Backend extends PHPUnit_Framework_TestCase {
* @return string
*/
public function getUser() {
- return uniqid('test_');
+ return $this->getUniqueID('test_');
}
public function testAddRemove() {
@@ -68,29 +68,29 @@ abstract class Test_User_Backend extends PHPUnit_Framework_TestCase {
$this->assertTrue((array_search($name1, $this->backend->getUsers())!==false));
$this->assertFalse((array_search($name2, $this->backend->getUsers())!==false));
}
-
+
public function testLogin() {
$name1=$this->getUser();
$name2=$this->getUser();
-
+
$this->assertFalse($this->backend->userExists($name1));
$this->assertFalse($this->backend->userExists($name2));
-
+
$this->backend->createUser($name1, 'pass1');
$this->backend->createUser($name2, 'pass2');
-
+
$this->assertTrue($this->backend->userExists($name1));
$this->assertTrue($this->backend->userExists($name2));
-
+
$this->assertSame($name1, $this->backend->checkPassword($name1, 'pass1'));
$this->assertSame($name2, $this->backend->checkPassword($name2, 'pass2'));
-
+
$this->assertFalse($this->backend->checkPassword($name1, 'pass2'));
$this->assertFalse($this->backend->checkPassword($name2, 'pass1'));
-
+
$this->assertFalse($this->backend->checkPassword($name1, 'dummy'));
$this->assertFalse($this->backend->checkPassword($name2, 'foobar'));
-
+
$this->backend->setPassword($name1, 'newpass1');
$this->assertFalse($this->backend->checkPassword($name1, 'pass1'));
$this->assertSame($name1, $this->backend->checkPassword($name1, 'newpass1'));
@@ -112,5 +112,4 @@ abstract class Test_User_Backend extends PHPUnit_Framework_TestCase {
$result = $this->backend->getDisplayNames('bar');
$this->assertSame(2, count($result));
}
-
}
diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php
index a8e497720c2..3a6be1ceee5 100644
--- a/tests/lib/user/database.php
+++ b/tests/lib/user/database.php
@@ -21,22 +21,27 @@
*/
class Test_User_Database extends Test_User_Backend {
+ /** @var array */
+ private $users;
+
public function getUser() {
$user = parent::getUser();
$this->users[]=$user;
return $user;
}
-
- public function setUp() {
+
+ protected function setUp() {
+ parent::setUp();
$this->backend=new OC_User_Database();
}
-
- public function tearDown() {
+
+ protected function tearDown() {
if(!isset($this->users)) {
return;
}
foreach($this->users as $user) {
$this->backend->deleteUser($user);
}
+ parent::tearDown();
}
}
diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php
index e417fd97603..fcc921de4b1 100644
--- a/tests/lib/user/dummy.php
+++ b/tests/lib/user/dummy.php
@@ -21,7 +21,8 @@
*/
class Test_User_Dummy extends Test_User_Backend {
- public function setUp() {
+ protected function setUp() {
+ parent::setUp();
$this->backend=new OC_User_Dummy();
}
}