diff --git a/lib/plugins/authpdo/_test/mysql.test.php b/lib/plugins/authpdo/_test/mysql.test.php index a04ccde59c1b6a5caa4af5ec642dd1062bb25736..1fc1473493270f93959e274f277bfbdb654f8407 100644 --- a/lib/plugins/authpdo/_test/mysql.test.php +++ b/lib/plugins/authpdo/_test/mysql.test.php @@ -83,16 +83,35 @@ class mysql_plugin_authpdo_test extends DokuWikiTest { $pdo = null; } + /** + * 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 1ea2783d471a339fb7b9499a21e677d9bcc94435..f0d93f0f6a1ce80d43eae9abe715bd2f875efe55 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,