/** * Remove created databases. * * @return void */ function __destruct() { if (empty($this->databases)) { return; } $database = new Database(HELPER_MYSQL_DSN, HELPER_MYSQL_USERNAME, HELPER_MYSQL_PASSWORD); foreach ($this->databases as $databaseName) { $database->exec('DROP DATABASE ' . $databaseName); } }
function case_template_schema_iterator() { $this->given($sqlite = $this->helper->sqlite(), $database = new CUT($sqlite))->when($result = $database->getTemplateSchemaIterator())->then->object($result)->isInstanceOf('Hoa\\File\\Finder')->foreach($result, function ($test, $value, $key) { $test->string($key)->match('/\\.sqlite.sql/')->object($value)->isInstanceOf('Hoa\\File\\SplFileInfo')->string($value->getFilename())->match('/\\.sqlite.sql/'); }); }
/** * Create the administrator profile. * * @param Configuration $configuration Configuration. * @param Database $database Database. * @param string $email Administrator's email. * @param string $password Administrator's password. * @return bool * @throw Exception\Installation */ static function createAdministratorProfile(Configuration $configuration, Database $database, $email, $password) { $login = Server::ADMINISTRATOR_LOGIN; if (false === static::checkLogin($login)) { throw new Exception\Installation('Login is invalid.', 13); } if (false === static::checkEmail($email . $email)) { throw new Exception\Installation('Email is invalid.', 14); } if (false === static::checkPassword($password . $password)) { throw new Exception\Installation('Password is invalid.', 15); } $digest = User::hashPassword($password); try { $statement = $database->prepare('INSERT INTO principals (uri, email, displayname) ' . 'VALUES (:uri, :email, :displayname)'); $statement->execute(['uri' => 'principals/' . $login, 'email' => $email, 'displayname' => 'Administrator']); $statement->execute(['uri' => 'principals/' . $login . '/calendar-proxy-read', 'email' => null, 'displayname' => null]); $statement->execute(['uri' => 'principals/' . $login . '/calendar-proxy-write', 'email' => null, 'displayname' => null]); $statement = $database->prepare('INSERT INTO users (username, digesta1) ' . 'VALUES (:username, :digest)'); $statement->execute(['username' => $login, 'digest' => $digest]); } catch (PDOException $exception) { throw new Exception\Installation('An error occured while creating the administrator profile.', 16, null, $exception); } return true; }