UserAdmin Class: remove
This commit is contained in:
parent
7785baa793
commit
b70dc95c6c
@ -56,6 +56,7 @@ class UserAdmin {
|
|||||||
* 'realname' => 'Eric Chiu', // (optional)
|
* 'realname' => 'Eric Chiu', // (optional)
|
||||||
* 'email' => 'eric@example.tw', // (optional)
|
* 'email' => 'eric@example.tw', // (optional)
|
||||||
* 'memo' => '' ) // (optional)
|
* 'memo' => '' ) // (optional)
|
||||||
|
* @throw UElearning\User\Exception\UserIdExistException
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public function create($userInfoArray) {
|
public function create($userInfoArray) {
|
||||||
@ -145,5 +146,30 @@ class UserAdmin {
|
|||||||
if( $info != null ) return true;
|
if( $info != null ) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除此使用者
|
||||||
|
*
|
||||||
|
* @param string $userName 帳號名稱
|
||||||
|
* @throw UElearning\User\Exception\UserNoFoundException
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public function remove($userName) {
|
||||||
|
|
||||||
|
// 若有此使用者
|
||||||
|
if($this->isExist($userName)) {
|
||||||
|
|
||||||
|
// TODO: 檢查所有關聯的資料,確認是否可以移除
|
||||||
|
|
||||||
|
// 移除資料庫中的使用者
|
||||||
|
$db = new Database\DBUser();
|
||||||
|
$db->deleteUser($userName);
|
||||||
|
}
|
||||||
|
// 若沒有這位使用者
|
||||||
|
else {
|
||||||
|
throw new Exception\UserNoFoundException($userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -71,12 +71,14 @@ class UserAdminTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeleteUser($uId)
|
public function testDeleteUser($uId)
|
||||||
{
|
{
|
||||||
// TODO: 待UserAdmin的移除功能寫好後,請改用UserAdmin
|
|
||||||
require_once UELEARNING_LIB_ROOT.'/Database/DBUser.php';
|
|
||||||
|
|
||||||
// 建立資料庫管理物件
|
// 建立資料庫管理物件
|
||||||
$db = new Database\DBUser();
|
$userAdmin = new UserAdmin();
|
||||||
$db->deleteUser($uId);
|
|
||||||
|
// 移除此使用者
|
||||||
|
$userAdmin->remove($uId);
|
||||||
|
|
||||||
|
// 檢查是否已確實建立
|
||||||
|
$this->assertEquals($userAdmin->isExist($uId), false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user