public function create(UserAccountModel $user) { global $DB, $CONFIG; // TODO should check email and username not already exist and nice error $stat = $DB->prepare("INSERT INTO user_account_information (username, username_canonical, email, email_canonical, password_hash, created_at, is_editor) " . "VALUES (:username, :username_canonical, :email, :email_canonical, :password_hash, :created_at, :is_editor) RETURNING id"); $stat->execute(array('username' => substr($user->getUsername(), 0, VARCHAR_COLUMN_LENGTH_USED), 'username_canonical' => substr(UserAccountModel::makeCanonicalUserName($user->getUsername()), 0, VARCHAR_COLUMN_LENGTH_USED), 'email' => substr($user->getEmail(), 0, VARCHAR_COLUMN_LENGTH_USED), 'email_canonical' => substr(UserAccountModel::makeCanonicalEmail($user->getEmail()), 0, VARCHAR_COLUMN_LENGTH_USED), 'password_hash' => $user->getPasswordHash(), 'created_at' => \TimeSource::getFormattedForDataBase(), 'is_editor' => $CONFIG->newUsersAreEditors ? 1 : 0)); $data = $stat->fetch(); $user->setId($data['id']); }
protected function checkUserInTest1(UserAccountModel $user) { $this->assertEquals("test", $user->getUsername()); $this->assertEquals("*****@*****.**", $user->getEmail()); $this->assertEquals(false, $user->checkPassword("1234")); $this->assertEquals(true, $user->checkPassword("password")); $this->assertEquals(false, $user->getIsEmailVerified()); $this->assertEquals(false, $user->getIsSystemAdmin()); $this->assertEquals(true, $user->getIsEditor()); }