aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/authpdo/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2016-02-12 20:16:40 +0100
committerAndreas Gohr <andi@splitbrain.org>2016-02-12 20:16:40 +0100
commit964d95c6130dddb157480af3e30604388849f24f (patch)
treeb416c9a6a712da5579a37e222b889c2e1e9be1ca /lib/plugins/authpdo/_test
parent14119d44248a8e38fe695b9761f0d359df30fe1e (diff)
downloaddokuwiki-964d95c6130dddb157480af3e30604388849f24f.tar.gz
dokuwiki-964d95c6130dddb157480af3e30604388849f24f.zip
added a few more tests for wordpress
Diffstat (limited to 'lib/plugins/authpdo/_test')
-rw-r--r--lib/plugins/authpdo/_test/mysql.test.php48
-rw-r--r--lib/plugins/authpdo/_test/mysql/wordpress.php27
2 files changed, 68 insertions, 7 deletions
diff --git a/lib/plugins/authpdo/_test/mysql.test.php b/lib/plugins/authpdo/_test/mysql.test.php
index a04ccde59..1fc147349 100644
--- a/lib/plugins/authpdo/_test/mysql.test.php
+++ b/lib/plugins/authpdo/_test/mysql.test.php
@@ -84,15 +84,34 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
}
/**
+ * Run general tests on all users
+ *
+ * @param auth_plugin_authpdo $auth
+ * @param array $users
+ */
+ protected function runGeneralTests(auth_plugin_authpdo $auth, $users) {
+ $this->assertTrue($auth->success, 'intialize auth');
+
+ if($auth->canDo('getUsers')) {
+ $list = $auth->retrieveUsers();
+ $this->assertGreaterThanOrEqual(count($users), count($list));
+ }
+
+ if($auth->canDo('getUserCount')) {
+ $count = $auth->getUserCount();
+ $this->assertGreaterThanOrEqual(count($users), $count);
+ }
+ }
+
+ /**
* run all the tests with the given user, depending on the capabilities
*
* @param auth_plugin_authpdo $auth
* @param $user
*/
- protected function runTests(auth_plugin_authpdo $auth, $user) {
+ protected function runUserTests(auth_plugin_authpdo $auth, $user) {
global $conf;
$info = 'testing ' . $user['user'];
- $this->assertTrue($auth->success, $info);
// minimal setup
$this->assertTrue($auth->checkPass($user['user'], $user['pass']), $info);
@@ -103,6 +122,26 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
$groups = array_merge($user['grps'], array($conf['defaultgroup']));
$this->assertEquals($groups, $check['grps'], $info);
+ // getUsers
+ if($auth->canDo('getUsers')) {
+ $list = $auth->retrieveUsers(0, -1, array('user' => $user['user']));
+ $this->assertGreaterThanOrEqual(1, count($list));
+ $list = $auth->retrieveUsers(0, -1, array('name' => $user['name']));
+ $this->assertGreaterThanOrEqual(1, count($list));
+ $list = $auth->retrieveUsers(0, -1, array('mail' => $user['mail']));
+ $this->assertGreaterThanOrEqual(1, count($list));
+ }
+
+ // getUserCount
+ if($auth->canDo('getUserCount')) {
+ $count = $auth->getUserCount(array('user' => $user['user']));
+ $this->assertGreaterThanOrEqual(1, $count);
+ $count = $auth->getUserCount(array('name' => $user['name']));
+ $this->assertGreaterThanOrEqual(1, $count);
+ $count = $auth->getUserCount(array('mail' => $user['mail']));
+ $this->assertGreaterThanOrEqual(1, $count);
+ }
+
// modPass
if($auth->canDo('modPass')) {
$newpass = 'foobar';
@@ -131,7 +170,7 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
// modLogin
if($auth->canDo('modLogin')) {
- $newuser = 'foobar'.$user['user'];
+ $newuser = 'foobar' . $user['user'];
$ok = $auth->modifyUser($user['user'], array('user' => $newuser));
$this->assertTrue($ok, $info);
$check = $auth->getUserData($newuser);
@@ -168,8 +207,9 @@ class mysql_plugin_authpdo_test extends DokuWikiTest {
if($data['passcrypt']) $conf['passcrypt'] = $data['passcrypt'];
$auth = new auth_plugin_authpdo();
+ $this->runGeneralTests($auth, $data['users']);
foreach($data['users'] as $user) {
- $this->runTests($auth, $user);
+ $this->runUserTests($auth, $user);
}
$this->dropDatabase();
diff --git a/lib/plugins/authpdo/_test/mysql/wordpress.php b/lib/plugins/authpdo/_test/mysql/wordpress.php
index 1ea2783d4..f0d93f0f6 100644
--- a/lib/plugins/authpdo/_test/mysql/wordpress.php
+++ b/lib/plugins/authpdo/_test/mysql/wordpress.php
@@ -19,7 +19,7 @@ $data = array(
WHERE user_login = :user
',
'select-user-groups' => '
- SELECT CONCAT("group",meta_value) as `group`
+ SELECT CONCAT("group",meta_value) AS `group`
FROM wpvk_usermeta
WHERE user_id = :uid
AND meta_key = "wpvk_user_level"
@@ -27,8 +27,29 @@ $data = array(
'select-groups' => '',
'insert-user' => '',
'delete-user' => '',
- 'list-users' => '',
- 'count-users' => '',
+ 'list-users' => '
+ SELECT DISTINCT user_login AS user
+ FROM wpvk_users U, wpvk_usermeta M
+ WHERE U.ID = M.user_id
+ AND M.meta_key = "wpvk_user_level"
+ AND CONCAT("group", M.meta_value) LIKE :group
+ AND U.user_login LIKE :user
+ AND U.display_name LIKE :name
+ AND U.user_email LIKE :mail
+ ORDER BY user_login
+ LIMIT :limit
+ OFFSET :start
+ ',
+ 'count-users' => '
+ SELECT COUNT(DISTINCT user_login) as `count`
+ FROM wpvk_users U, wpvk_usermeta M
+ WHERE U.ID = M.user_id
+ AND M.meta_key = "wpvk_user_level"
+ AND CONCAT("group", M.meta_value) LIKE :group
+ AND U.user_login LIKE :user
+ AND U.display_name LIKE :name
+ AND U.user_email LIKE :mail
+ ',
'update-user-info' => '
UPDATE wpvk_users
SET display_name = :name,