summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/cache/file.php2
-rw-r--r--tests/lib/files/etagtest.php4
-rw-r--r--tests/lib/files/filesystem.php4
-rw-r--r--tests/lib/files/node/file.php2
-rw-r--r--tests/lib/files/node/folder.php2
-rw-r--r--tests/lib/files/node/integration.php2
-rw-r--r--tests/lib/files/node/node.php2
-rw-r--r--tests/lib/files/node/root.php2
-rw-r--r--tests/lib/files/storage/wrapper/jail.php2
-rw-r--r--tests/lib/files/type/detection.php66
-rw-r--r--tests/lib/files/utils/scanner.php4
-rw-r--r--tests/lib/files/view.php45
-rw-r--r--tests/lib/group.php6
-rw-r--r--tests/lib/preview.php2
-rw-r--r--tests/lib/preview/provider.php2
-rw-r--r--tests/lib/testcase.php2
-rw-r--r--tests/lib/traits/usertrait.php4
-rw-r--r--tests/lib/user.php2
-rw-r--r--tests/lib/user/avataruserdummy.php2
-rw-r--r--tests/lib/user/dummy.php2
-rw-r--r--tests/lib/user/manager.php92
-rw-r--r--tests/lib/user/session.php22
-rw-r--r--tests/lib/user/user.php24
-rw-r--r--tests/lib/util/user/dummy.php173
24 files changed, 345 insertions, 125 deletions
diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php
index 94001291d86..b5f186c5416 100644
--- a/tests/lib/cache/file.php
+++ b/tests/lib/cache/file.php
@@ -60,7 +60,7 @@ class FileCache extends \Test_Cache {
\OC_Config::setValue('cachedirectory', $datadir);
\OC_User::clearBackends();
- \OC_User::useBackend(new \OC_User_Dummy());
+ \OC_User::useBackend(new \Test\Util\User\Dummy());
//login
\OC_User::createUser('test', 'test');
diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php
index c3d364d6800..1a11b29cf00 100644
--- a/tests/lib/files/etagtest.php
+++ b/tests/lib/files/etagtest.php
@@ -17,7 +17,7 @@ class EtagTest extends \Test\TestCase {
private $tmpDir;
/**
- * @var \OC_User_Dummy $userBackend
+ * @var \Test\Util\User\Dummy $userBackend
*/
private $userBackend;
@@ -35,7 +35,7 @@ class EtagTest extends \Test\TestCase {
$this->tmpDir = \OC_Helper::tmpFolder();
\OC_Config::setValue('datadirectory', $this->tmpDir);
- $this->userBackend = new \OC_User_Dummy();
+ $this->userBackend = new \Test\Util\User\Dummy();
\OC_User::useBackend($this->userBackend);
}
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index b7061bd19a0..cc01ed70b5d 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -72,7 +72,7 @@ class Filesystem extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $userBackend = new \OC_User_Dummy();
+ $userBackend = new \Test\Util\User\Dummy();
$userBackend->createUser(self::TEST_FILESYSTEM_USER1, self::TEST_FILESYSTEM_USER1);
$userBackend->createUser(self::TEST_FILESYSTEM_USER2, self::TEST_FILESYSTEM_USER2);
\OC::$server->getUserManager()->registerBackend($userBackend);
@@ -274,7 +274,7 @@ class Filesystem extends \Test\TestCase {
$user = \OC_User::getUser();
} else {
$user = self::TEST_FILESYSTEM_USER1;
- $backend = new \OC_User_Dummy();
+ $backend = new \Test\Util\User\Dummy();
\OC_User::useBackend($backend);
$backend->createUser($user, $user);
$userObj = \OC::$server->getUserManager()->get($user);
diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php
index e3b8019b4ca..c431a2eb366 100644
--- a/tests/lib/files/node/file.php
+++ b/tests/lib/files/node/file.php
@@ -18,7 +18,7 @@ class File extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->user = new \OC\User\User('', new \OC_User_Dummy);
+ $this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
protected function getFileInfo($data) {
diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php
index 96795cb02ef..b30f352847d 100644
--- a/tests/lib/files/node/folder.php
+++ b/tests/lib/files/node/folder.php
@@ -21,7 +21,7 @@ class Folder extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->user = new \OC\User\User('', new \OC_User_Dummy);
+ $this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
protected function getFileInfo($data) {
diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/integration.php
index 2d5ccd1fb85..5580b40a126 100644
--- a/tests/lib/files/node/integration.php
+++ b/tests/lib/files/node/integration.php
@@ -36,7 +36,7 @@ class IntegrationTests extends \Test\TestCase {
\OC_Hook::clear('OC_Filesystem');
- $user = new User($this->getUniqueID('user'), new \OC_User_Dummy);
+ $user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy);
$this->loginAsUser($user->getUID());
$this->view = new View();
diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php
index 01ed84c4a06..afcf4cbabaa 100644
--- a/tests/lib/files/node/node.php
+++ b/tests/lib/files/node/node.php
@@ -15,7 +15,7 @@ class Node extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->user = new \OC\User\User('', new \OC_User_Dummy);
+ $this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
protected function getFileInfo($data) {
diff --git a/tests/lib/files/node/root.php b/tests/lib/files/node/root.php
index a763428209c..4b1aea1da4e 100644
--- a/tests/lib/files/node/root.php
+++ b/tests/lib/files/node/root.php
@@ -17,7 +17,7 @@ class Root extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->user = new \OC\User\User('', new \OC_User_Dummy);
+ $this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
}
protected function getFileInfo($data) {
diff --git a/tests/lib/files/storage/wrapper/jail.php b/tests/lib/files/storage/wrapper/jail.php
index a7bd684df44..9b16bc5a321 100644
--- a/tests/lib/files/storage/wrapper/jail.php
+++ b/tests/lib/files/storage/wrapper/jail.php
@@ -30,7 +30,7 @@ class Jail extends \Test\Files\Storage\Storage {
$contents = array();
$dh = $this->sourceStorage->opendir('');
while ($file = readdir($dh)) {
- if ($file !== '.' and $file !== '..') {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
$contents[] = $file;
}
}
diff --git a/tests/lib/files/type/detection.php b/tests/lib/files/type/detection.php
index 1997fa4dfd6..5800f4eb8e3 100644
--- a/tests/lib/files/type/detection.php
+++ b/tests/lib/files/type/detection.php
@@ -19,58 +19,64 @@
*
*/
-namespace OC\Files\Type;
+namespace Test\Files\Type;
use \OC\Files\Type\Detection;
class DetectionTest extends \Test\TestCase {
+ /** @var Detection */
+ private $detection;
+
+ public function setUp() {
+ parent::setUp();
+ $this->detection = new Detection(
+ \OC::$server->getURLGenerator(),
+ \OC::$SERVERROOT . '/config/',
+ \OC::$SERVERROOT . '/resources/config/'
+ );
+ }
public function testDetect() {
- $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir);
$dir = \OC::$SERVERROOT.'/tests/data';
- $result = $detection->detect($dir."/");
+ $result = $this->detection->detect($dir."/");
$expected = 'httpd/unix-directory';
$this->assertEquals($expected, $result);
- $result = $detection->detect($dir."/data.tar.gz");
+ $result = $this->detection->detect($dir."/data.tar.gz");
$expected = 'application/x-gzip';
$this->assertEquals($expected, $result);
- $result = $detection->detect($dir."/data.zip");
+ $result = $this->detection->detect($dir."/data.zip");
$expected = 'application/zip';
$this->assertEquals($expected, $result);
- $result = $detection->detect($dir."/testimagelarge.svg");
+ $result = $this->detection->detect($dir."/testimagelarge.svg");
$expected = 'image/svg+xml';
$this->assertEquals($expected, $result);
- $result = $detection->detect($dir."/testimage.png");
+ $result = $this->detection->detect($dir."/testimage.png");
$expected = 'image/png';
$this->assertEquals($expected, $result);
}
public function testGetSecureMimeType() {
- $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir);
-
- $result = $detection->getSecureMimeType('image/svg+xml');
+ $result = $this->detection->getSecureMimeType('image/svg+xml');
$expected = 'text/plain';
$this->assertEquals($expected, $result);
- $result = $detection->getSecureMimeType('image/png');
+ $result = $this->detection->getSecureMimeType('image/png');
$expected = 'image/png';
$this->assertEquals($expected, $result);
}
public function testDetectPath() {
- $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir);
-
- $this->assertEquals('text/plain', $detection->detectPath('foo.txt'));
- $this->assertEquals('image/png', $detection->detectPath('foo.png'));
- $this->assertEquals('image/png', $detection->detectPath('foo.bar.png'));
- $this->assertEquals('application/octet-stream', $detection->detectPath('.png'));
- $this->assertEquals('application/octet-stream', $detection->detectPath('foo'));
- $this->assertEquals('application/octet-stream', $detection->detectPath(''));
+ $this->assertEquals('text/plain', $this->detection->detectPath('foo.txt'));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.png'));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.bar.png'));
+ $this->assertEquals('application/octet-stream', $this->detection->detectPath('.png'));
+ $this->assertEquals('application/octet-stream', $this->detection->detectPath('foo'));
+ $this->assertEquals('application/octet-stream', $this->detection->detectPath(''));
}
public function testDetectString() {
@@ -78,16 +84,14 @@ class DetectionTest extends \Test\TestCase {
$this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows');
}
- $detection = new Detection(\OC::$server->getURLGenerator(), \OC::$configDir);
-
- $result = $detection->detectString("/data/data.tar.gz");
+ $result = $this->detection->detectString("/data/data.tar.gz");
$expected = 'text/plain; charset=us-ascii';
$this->assertEquals($expected, $result);
}
public function testMimeTypeIcon() {
if (!class_exists('org\\bovigo\\vfs\\vfsStream')) {
- $this->markTestSkipped('Pacakge vfsStream not installed');
+ $this->markTestSkipped('Package vfsStream not installed');
}
$confDir = \org\bovigo\vfs\vfsStream::setup();
$mimetypealiases_dist = \org\bovigo\vfs\vfsStream::newFile('mimetypealiases.dist.json')->at($confDir);
@@ -111,7 +115,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/folder.png'))
->willReturn('folder.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('dir');
$this->assertEquals('folder.svg', $mimeType);
@@ -130,7 +134,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/folder-shared.png'))
->willReturn('folder-shared.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('dir-shared');
$this->assertEquals('folder-shared.svg', $mimeType);
@@ -150,7 +154,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/folder-external.png'))
->willReturn('folder-external.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('dir-external');
$this->assertEquals('folder-external.svg', $mimeType);
@@ -170,7 +174,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/my-type.png'))
->willReturn('my-type.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('my-type');
$this->assertEquals('my-type.svg', $mimeType);
@@ -200,7 +204,7 @@ class DetectionTest extends \Test\TestCase {
}
));
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('my-type');
$this->assertEquals('my.svg', $mimeType);
@@ -231,7 +235,7 @@ class DetectionTest extends \Test\TestCase {
}
));
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('foo-bar');
$this->assertEquals('file.svg', $mimeType);
@@ -250,7 +254,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/foo-bar.png'))
->willReturn('foo-bar.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('foo-bar');
$this->assertEquals('foo-bar.svg', $mimeType);
$mimeType = $detection->mimeTypeIcon('foo-bar');
@@ -276,7 +280,7 @@ class DetectionTest extends \Test\TestCase {
->with($this->equalTo('core'), $this->equalTo('filetypes/foobar-baz.png'))
->willReturn('foobar-baz.svg');
- $detection = new Detection($urlGenerator, $confDir->url());
+ $detection = new Detection($urlGenerator, $confDir->url(), $confDir->url());
$mimeType = $detection->mimeTypeIcon('foo');
$this->assertEquals('foobar-baz.svg', $mimeType);
}
diff --git a/tests/lib/files/utils/scanner.php b/tests/lib/files/utils/scanner.php
index 75cd75ee3f5..5492774f42e 100644
--- a/tests/lib/files/utils/scanner.php
+++ b/tests/lib/files/utils/scanner.php
@@ -42,14 +42,14 @@ class TestScanner extends \OC\Files\Utils\Scanner {
class Scanner extends \Test\TestCase {
/**
- * @var \OC_User_Dummy
+ * @var \Test\Util\User\Dummy
*/
private $userBackend;
protected function setUp() {
parent::setUp();
- $this->userBackend = new \OC_User_Dummy();
+ $this->userBackend = new \Test\Util\User\Dummy();
\OC::$server->getUserManager()->registerBackend($this->userBackend);
$this->loginAsUser();
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 4a2dc65afce..56269ec5ad2 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -68,7 +68,7 @@ class View extends \Test\TestCase {
\OC_Hook::clear();
\OC_User::clearBackends();
- \OC_User::useBackend(new \OC_User_Dummy());
+ \OC_User::useBackend(new \Test\Util\User\Dummy());
//login
$userManager = \OC::$server->getUserManager();
@@ -1893,6 +1893,49 @@ class View extends \Test\TestCase {
}
/**
+ * simulate a failed copy operation.
+ * We expect that we catch the exception, free the lock and re-throw it.
+ *
+ * @expectedException \Exception
+ */
+ public function testLockFileCopyException() {
+ $view = new \OC\Files\View('/' . $this->user . '/files/');
+
+ $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary')
+ ->setMethods(['copy'])
+ ->getMock();
+
+ $sourcePath = 'original.txt';
+ $targetPath = 'target.txt';
+
+ \OC\Files\Filesystem::mount($storage, array(), $this->user . '/');
+ $storage->mkdir('files');
+ $view->file_put_contents($sourcePath, 'meh');
+
+ $storage->expects($this->once())
+ ->method('copy')
+ ->will($this->returnCallback(
+ function() {
+ throw new \Exception();
+ }
+ ));
+
+ $this->connectMockHooks('copy', $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost);
+ $this->connectMockHooks('copy', $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost);
+
+ $this->assertNull($this->getFileLockType($view, $sourcePath), 'Source file not locked before operation');
+ $this->assertNull($this->getFileLockType($view, $targetPath), 'Target file not locked before operation');
+
+ try {
+ $view->copy($sourcePath, $targetPath);
+ } catch (\Exception $e) {
+ $this->assertNull($this->getFileLockType($view, $sourcePath), 'Source file not locked after operation');
+ $this->assertNull($this->getFileLockType($view, $targetPath), 'Target file not locked after operation');
+ throw $e;
+ }
+ }
+
+ /**
* Test rename operation: unlock first path when second path was locked
*/
public function testLockFileRenameUnlockOnException() {
diff --git a/tests/lib/group.php b/tests/lib/group.php
index 795de695513..066dddc738e 100644
--- a/tests/lib/group.php
+++ b/tests/lib/group.php
@@ -30,7 +30,7 @@ class Test_Group extends \Test\TestCase {
}
public function testSingleBackend() {
- $userBackend = new \OC_User_Dummy();
+ $userBackend = new \Test\Util\User\Dummy();
\OC_User::getManager()->registerBackend($userBackend);
OC_Group::useBackend(new OC_Group_Dummy());
@@ -112,7 +112,7 @@ class Test_Group extends \Test\TestCase {
public function testUsersInGroup() {
OC_Group::useBackend(new OC_Group_Dummy());
- $userBackend = new \OC_User_Dummy();
+ $userBackend = new \Test\Util\User\Dummy();
\OC_User::getManager()->registerBackend($userBackend);
$group1 = $this->getUniqueID();
@@ -141,7 +141,7 @@ class Test_Group extends \Test\TestCase {
}
public function testMultiBackend() {
- $userBackend = new \OC_User_Dummy();
+ $userBackend = new \Test\Util\User\Dummy();
\OC_User::getManager()->registerBackend($userBackend);
$backend1 = new OC_Group_Dummy();
$backend2 = new OC_Group_Dummy();
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 82ee8e2eca2..9e118014bac 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -61,7 +61,7 @@ class Preview extends TestCase {
$userManager = \OC::$server->getUserManager();
$userManager->clearBackends();
- $backend = new \OC_User_Dummy();
+ $backend = new \Test\Util\User\Dummy();
$userManager->registerBackend($backend);
$backend->createUser(self::TEST_PREVIEW_USER1, self::TEST_PREVIEW_USER1);
$this->loginAsUser(self::TEST_PREVIEW_USER1);
diff --git a/tests/lib/preview/provider.php b/tests/lib/preview/provider.php
index 02459b83bb3..5377f30df82 100644
--- a/tests/lib/preview/provider.php
+++ b/tests/lib/preview/provider.php
@@ -49,7 +49,7 @@ abstract class Provider extends \Test\TestCase {
$userManager = \OC::$server->getUserManager();
$userManager->clearBackends();
- $backend = new \OC_User_Dummy();
+ $backend = new \Test\Util\User\Dummy();
$userManager->registerBackend($backend);
$userId = $this->getUniqueID();
diff --git a/tests/lib/testcase.php b/tests/lib/testcase.php
index 854d5f4f65b..7e4890a46c2 100644
--- a/tests/lib/testcase.php
+++ b/tests/lib/testcase.php
@@ -193,7 +193,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase {
static protected function tearDownAfterClassCleanStrayDataUnlinkDir($dir) {
if ($dh = @opendir($dir)) {
while (($file = readdir($dh)) !== false) {
- if ($file === '..' || $file === '.') {
+ if (\OC\Files\Filesystem::isIgnoredDir($file)) {
continue;
}
$path = $dir . '/' . $file;
diff --git a/tests/lib/traits/usertrait.php b/tests/lib/traits/usertrait.php
index 401d8b8a832..229087a5200 100644
--- a/tests/lib/traits/usertrait.php
+++ b/tests/lib/traits/usertrait.php
@@ -13,7 +13,7 @@ namespace Test\Traits;
*/
trait UserTrait {
/**
- * @var \OC_User_Dummy|\OCP\UserInterface
+ * @var \Test\Util\User\Dummy|\OCP\UserInterface
*/
protected $userBackend;
@@ -22,7 +22,7 @@ trait UserTrait {
}
protected function setUpUserTrait() {
- $this->userBackend = new \OC_User_Dummy();
+ $this->userBackend = new \Test\Util\User\Dummy();
\OC::$server->getUserManager()->registerBackend($this->userBackend);
}
diff --git a/tests/lib/user.php b/tests/lib/user.php
index cb0c661b2a4..3c068be2826 100644
--- a/tests/lib/user.php
+++ b/tests/lib/user.php
@@ -18,7 +18,7 @@ class User extends TestCase {
protected function setUp(){
parent::setUp();
- $this->backend = $this->getMock('\OC_User_Dummy');
+ $this->backend = $this->getMock('\Test\Util\User\Dummy');
$manager = \OC_User::getManager();
$manager->registerBackend($this->backend);
}
diff --git a/tests/lib/user/avataruserdummy.php b/tests/lib/user/avataruserdummy.php
index 738b10492ea..086adb6043f 100644
--- a/tests/lib/user/avataruserdummy.php
+++ b/tests/lib/user/avataruserdummy.php
@@ -20,7 +20,7 @@
*
*/
-class Avatar_User_Dummy extends \OC_User_Dummy {
+class Avatar_User_Dummy extends \Test\Util\User\Dummy {
public function canChangeAvatar($uid) {
return true;
}
diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php
index fcc921de4b1..c6c79d7a860 100644
--- a/tests/lib/user/dummy.php
+++ b/tests/lib/user/dummy.php
@@ -23,6 +23,6 @@
class Test_User_Dummy extends Test_User_Backend {
protected function setUp() {
parent::setUp();
- $this->backend=new OC_User_Dummy();
+ $this->backend=new \Test\Util\User\Dummy();
}
}
diff --git a/tests/lib/user/manager.php b/tests/lib/user/manager.php
index cc8bcd65896..df673f581c4 100644
--- a/tests/lib/user/manager.php
+++ b/tests/lib/user/manager.php
@@ -11,7 +11,7 @@ namespace Test\User;
class Manager extends \Test\TestCase {
public function testGetBackends() {
- $userDummyBackend = $this->getMock('\OC_User_Dummy');
+ $userDummyBackend = $this->getMock('\Test\Util\User\Dummy');
$manager = new \OC\User\Manager();
$manager->registerBackend($userDummyBackend);
$this->assertEquals([$userDummyBackend], $manager->getBackends());
@@ -23,9 +23,9 @@ class Manager extends \Test\TestCase {
public function testUserExistsSingleBackendExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
@@ -39,9 +39,9 @@ class Manager extends \Test\TestCase {
public function testUserExistsSingleBackendNotExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
@@ -61,18 +61,18 @@ class Manager extends \Test\TestCase {
public function testUserExistsTwoBackendsSecondExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
- $backend1 = $this->getMock('\OC_User_Dummy');
+ $backend1 = $this->getMock('\Test\Util\User\Dummy');
$backend1->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(false));
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
*/
- $backend2 = $this->getMock('\OC_User_Dummy');
+ $backend2 = $this->getMock('\Test\Util\User\Dummy');
$backend2->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
@@ -87,18 +87,18 @@ class Manager extends \Test\TestCase {
public function testUserExistsTwoBackendsFirstExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
- $backend1 = $this->getMock('\OC_User_Dummy');
+ $backend1 = $this->getMock('\Test\Util\User\Dummy');
$backend1->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(true));
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
*/
- $backend2 = $this->getMock('\OC_User_Dummy');
+ $backend2 = $this->getMock('\Test\Util\User\Dummy');
$backend2->expects($this->never())
->method('userExists');
@@ -113,7 +113,7 @@ class Manager extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('checkPassword')
->with($this->equalTo('foo'), $this->equalTo('bar'))
@@ -140,7 +140,7 @@ class Manager extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
->method('checkPassword');
@@ -156,9 +156,9 @@ class Manager extends \Test\TestCase {
public function testGetOneBackendExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
@@ -172,9 +172,9 @@ class Manager extends \Test\TestCase {
public function testGetOneBackendNotExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
@@ -188,9 +188,9 @@ class Manager extends \Test\TestCase {
public function testSearchOneBackend() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'))
@@ -207,18 +207,18 @@ class Manager extends \Test\TestCase {
public function testSearchTwoBackendLimitOffset() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
- $backend1 = $this->getMock('\OC_User_Dummy');
+ $backend1 = $this->getMock('\Test\Util\User\Dummy');
$backend1->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo1', 'foo2')));
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
*/
- $backend2 = $this->getMock('\OC_User_Dummy');
+ $backend2 = $this->getMock('\Test\Util\User\Dummy');
$backend2->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
@@ -237,9 +237,9 @@ class Manager extends \Test\TestCase {
public function testCreateUserSingleBackendNotExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnValue(true));
@@ -265,9 +265,9 @@ class Manager extends \Test\TestCase {
*/
public function testCreateUserSingleBackendExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnValue(true));
@@ -288,9 +288,9 @@ class Manager extends \Test\TestCase {
public function testCreateUserSingleBackendNotSupported() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnValue(false));
@@ -320,9 +320,9 @@ class Manager extends \Test\TestCase {
*/
public function testCreateUserTwoBackendExists() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
- $backend1 = $this->getMock('\OC_User_Dummy');
+ $backend1 = $this->getMock('\Test\Util\User\Dummy');
$backend1->expects($this->any())
->method('implementsActions')
->will($this->returnValue(true));
@@ -336,9 +336,9 @@ class Manager extends \Test\TestCase {
->will($this->returnValue(false));
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
*/
- $backend2 = $this->getMock('\OC_User_Dummy');
+ $backend2 = $this->getMock('\Test\Util\User\Dummy');
$backend2->expects($this->any())
->method('implementsActions')
->will($this->returnValue(true));
@@ -368,9 +368,9 @@ class Manager extends \Test\TestCase {
public function testCountUsersOneBackend() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('countUsers')
->will($this->returnValue(7));
@@ -382,14 +382,14 @@ class Manager extends \Test\TestCase {
$backend->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_OC_User_Dummy'));
+ ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
$manager = new \OC\User\Manager();
$manager->registerBackend($backend);
$result = $manager->countUsers();
$keys = array_keys($result);
- $this->assertTrue(strpos($keys[0], 'Mock_OC_User_Dummy') !== false);
+ $this->assertTrue(strpos($keys[0], 'Mock_Test_Util_User_Dummy') !== false);
$users = array_shift($result);
$this->assertEquals(7, $users);
@@ -397,9 +397,9 @@ class Manager extends \Test\TestCase {
public function testCountUsersTwoBackends() {
/**
- * @var \OC_User_Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend1 = $this->getMock('\OC_User_Dummy');
+ $backend1 = $this->getMock('\Test\Util\User\Dummy');
$backend1->expects($this->once())
->method('countUsers')
->will($this->returnValue(7));
@@ -410,9 +410,9 @@ class Manager extends \Test\TestCase {
->will($this->returnValue(true));
$backend1->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_OC_User_Dummy'));
+ ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
- $backend2 = $this->getMock('\OC_User_Dummy');
+ $backend2 = $this->getMock('\Test\Util\User\Dummy');
$backend2->expects($this->once())
->method('countUsers')
->will($this->returnValue(16));
@@ -423,7 +423,7 @@ class Manager extends \Test\TestCase {
->will($this->returnValue(true));
$backend2->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_OC_User_Dummy'));
+ ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
$manager = new \OC\User\Manager();
$manager->registerBackend($backend1);
@@ -433,7 +433,7 @@ class Manager extends \Test\TestCase {
//because the backends have the same class name, only one value expected
$this->assertEquals(1, count($result));
$keys = array_keys($result);
- $this->assertTrue(strpos($keys[0], 'Mock_OC_User_Dummy') !== false);
+ $this->assertTrue(strpos($keys[0], 'Mock_Test_Util_User_Dummy') !== false);
$users = array_shift($result);
//users from backends shall be summed up
@@ -442,7 +442,7 @@ class Manager extends \Test\TestCase {
public function testDeleteUser() {
$manager = new \OC\User\Manager();
- $backend = new \OC_User_Dummy();
+ $backend = new \Test\Util\User\Dummy();
$backend->createUser('foo', 'bar');
$manager->registerBackend($backend);
diff --git a/tests/lib/user/session.php b/tests/lib/user/session.php
index 4dc7f29c5b8..d9dace2ef05 100644
--- a/tests/lib/user/session.php
+++ b/tests/lib/user/session.php
@@ -20,7 +20,7 @@ class Session extends \Test\TestCase {
->with('user_id')
->will($this->returnValue('foo'));
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with('foo')
@@ -41,7 +41,7 @@ class Session extends \Test\TestCase {
->with('user_id')
->will($this->returnValue('foo'));
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('userExists')
->with('foo')
@@ -62,7 +62,7 @@ class Session extends \Test\TestCase {
->with('user_id')
->will($this->returnValue(null));
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
->method('userExists');
@@ -82,7 +82,7 @@ class Session extends \Test\TestCase {
$manager = $this->getMock('\OC\User\Manager');
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
$user->expects($this->once())
@@ -122,7 +122,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
$user->expects($this->once())
@@ -161,7 +161,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
$user->expects($this->once())
@@ -196,7 +196,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
$user->expects($this->never())
@@ -220,7 +220,7 @@ class Session extends \Test\TestCase {
$manager = $this->getMock('\OC\User\Manager');
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$manager->expects($this->once())
->method('checkPassword')
@@ -257,7 +257,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
@@ -305,7 +305,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
@@ -347,7 +347,7 @@ class Session extends \Test\TestCase {
}
$manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
- $backend = $this->getMock('OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php
index b1df975b60f..bc1365d35bf 100644
--- a/tests/lib/user/user.php
+++ b/tests/lib/user/user.php
@@ -74,7 +74,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('setPassword')
->with($this->equalTo('foo'), $this->equalTo('bar'));
@@ -97,7 +97,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
->method('setPassword');
@@ -182,7 +182,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('deleteUser')
->with($this->equalTo('foo'));
@@ -195,7 +195,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('getHome')
->with($this->equalTo('foo'))
@@ -216,7 +216,7 @@ class User extends \Test\TestCase {
}
public function testGetBackendClassName() {
- $user = new \OC\User\User('foo', new \OC_User_Dummy());
+ $user = new \OC\User\User('foo', new \Test\Util\User\Dummy());
$this->assertEquals('Dummy', $user->getBackendClassName());
$user = new \OC\User\User('foo', new \OC_User_Database());
$this->assertEquals('Database', $user->getBackendClassName());
@@ -226,7 +226,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->never())
->method('getHome');
@@ -253,7 +253,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
@@ -273,7 +273,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
@@ -287,7 +287,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
@@ -307,7 +307,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->any())
->method('implementsActions')
@@ -393,7 +393,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('setPassword');
@@ -434,7 +434,7 @@ class User extends \Test\TestCase {
/**
* @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend
*/
- $backend = $this->getMock('\OC_User_Dummy');
+ $backend = $this->getMock('\Test\Util\User\Dummy');
$backend->expects($this->once())
->method('deleteUser');
diff --git a/tests/lib/util/user/dummy.php b/tests/lib/util/user/dummy.php
new file mode 100644
index 00000000000..6e23e22ab67
--- /dev/null
+++ b/tests/lib/util/user/dummy.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ * @author Andreas Fischer <bantu@owncloud.com>
+ * @author Arthur Schiwon <blizzz@owncloud.com>
+ * @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
+ * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace Test\Util\User;
+
+use OC_User_Backend;
+
+/**
+ * dummy user backend, does not keep state, only for testing use
+ */
+class Dummy extends OC_User_Backend implements \OCP\IUserBackend {
+ private $users = array();
+ private $displayNames = array();
+
+ /**
+ * Create a new user
+ *
+ * @param string $uid The username of the user to create
+ * @param string $password The password of the new user
+ * @return bool
+ *
+ * Creates a new user. Basic checking of username is done in OC_User
+ * itself, not in its subclasses.
+ */
+ public function createUser($uid, $password) {
+ if (isset($this->users[$uid])) {
+ return false;
+ } else {
+ $this->users[$uid] = $password;
+ return true;
+ }
+ }
+
+ /**
+ * delete a user
+ *
+ * @param string $uid The username of the user to delete
+ * @return bool
+ *
+ * Deletes a user
+ */
+ public function deleteUser($uid) {
+ if (isset($this->users[$uid])) {
+ unset($this->users[$uid]);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Set password
+ *
+ * @param string $uid The username
+ * @param string $password The new password
+ * @return bool
+ *
+ * Change the password of a user
+ */
+ public function setPassword($uid, $password) {
+ if (isset($this->users[$uid])) {
+ $this->users[$uid] = $password;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check if the password is correct
+ *
+ * @param string $uid The username
+ * @param string $password The password
+ * @return string
+ *
+ * Check if the password is correct without logging in the user
+ * returns the user id or false
+ */
+ public function checkPassword($uid, $password) {
+ if (isset($this->users[$uid]) && $this->users[$uid] === $password) {
+ return $uid;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get a list of all users
+ *
+ * @param string $search
+ * @param null|int $limit
+ * @param null|int $offset
+ * @return string[] an array of all uids
+ */
+ public function getUsers($search = '', $limit = null, $offset = null) {
+ if (empty($search)) {
+ return array_keys($this->users);
+ }
+ $result = array();
+ foreach (array_keys($this->users) as $user) {
+ if (stripos($user, $search) !== false) {
+ $result[] = $user;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * check if a user exists
+ *
+ * @param string $uid the username
+ * @return boolean
+ */
+ public function userExists($uid) {
+ return isset($this->users[$uid]);
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasUserListings() {
+ return true;
+ }
+
+ /**
+ * counts the users in the database
+ *
+ * @return int|bool
+ */
+ public function countUsers() {
+ return 0;
+ }
+
+ public function setDisplayName($uid, $displayName) {
+ $this->displayNames[$uid] = $displayName;
+ }
+
+ public function getDisplayName($uid) {
+ return isset($this->displayNames[$uid])? $this->displayNames[$uid]: $uid;
+ }
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'Dummy';
+ }
+}