public function testSetNameInternal() { $u = new ae_UserModel(); $u->setNameInternal('my-user'); $this->assertEquals($u->getNameInternal(), 'my-user'); $u->setNameInternal(4); $this->assertTrue($u->getNameInternal() === '4'); $this->setExpectedException('Exception'); $u->setNameInternal(''); }
/** * Create the user. * @return {int} ID of the new user. */ function createUser() { if (!isset($_POST['user-name-internal'], $_POST['user-name-external'], $_POST['user-permalink'], $_POST['user-password'])) { header('Location: ../admin.php?error=missing_data_for_user'); exit; } $permalink = trim($_POST['user-permalink']); $status = isset($_POST['user-status-suspended']) ? ae_UserModel::STATUS_SUSPENDED : ae_UserModel::STATUS_ACTIVE; $user = new ae_UserModel(); if (isset($_POST['edit-id'])) { if (!$user->load($_POST['edit-id'])) { return FALSE; } } $user->setNameInternal($_POST['user-name-internal']); $user->setNameExternal($_POST['user-name-external']); if ($permalink != '') { $user->setPermalink($permalink); } if ($_POST['user-password'] !== '') { $user->setPasswordHash(ae_Security::hash($_POST['user-password'])); } $user->setStatus($status); $user->save(); return $user->getId(); }