public function testdeleteUser() { $created_by = 1; $_REQUEST['id'] = 3; $_SESSION['id'] = 1; $execute = true; if ($_REQUEST['id'] == $_SESSION['id']) { $execute = false; $msg = 'YOU CANNOT DELETE YOURSELF'; } if ($_REQUEST['id'] == $_SESSION['id']) { $execute = false; $msg = 'YOU CANNOT DELETE YOURSELF'; } if ($created_by != $_SESSION['id']) { $execute = false; $msg = 'YOU CANNOT DELETE THIS ENTRY BECAUSE YOU DIDNT CREATE THIS'; } if ($execute) { $objUsers = new um(); $arr = $objUsers->deleteUser(); if ($arr == true) { $msg = 'SUCCESS'; } else { $msg = 'ERROR'; } } $this->assertEquals('SUCCESS', $msg); }
public function deleteuser() { $id = $this->params[2]; if ($id == $_SESSION['id']) { header('location:' . BASE_URL . '/users/listusers/You Cannot delete yourself'); exit; } $objUsersModel = new UsersModel(); $usersArray = $objUsersModel->getSingleUser($id); if ($usersArray[0]['created_by'] != $_SESSION['id']) { header('location:' . BASE_URL . '/users/listusers/You Cannot delete this entry because you didnt create it'); exit; } if ($objUsersModel->deleteUser($id)) { header('location:' . BASE_URL . '/users/listusers'); exit; } }