This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/tests/bootstrap.php

45 lines
1.3 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
2020-03-13 09:23:54 +00:00
namespace Shimmie2;
chdir(dirname(dirname(__FILE__)));
require_once "core/sanitize_php.php";
require_once "vendor/autoload.php";
require_once "tests/defines.php";
require_once "core/sys_config.php";
require_once "core/polyfills.php";
require_once "core/util.php";
2015-08-09 11:14:28 +00:00
$_SERVER['QUERY_STRING'] = '/';
2023-12-31 18:41:08 +00:00
if (file_exists("data/test-trace.json")) {
unlink("data/test-trace.json");
2020-01-29 00:49:21 +00:00
}
2015-08-09 11:14:28 +00:00
global $cache, $config, $database, $user, $page, $_tracer;
_set_up_shimmie_environment();
2020-01-28 23:57:43 +00:00
$tracer_enabled = true;
$_tracer = new \EventTracer();
2020-01-28 23:57:43 +00:00
$_tracer->begin("bootstrap");
_load_core_files();
$cache = loadCache(CACHE_DSN);
2023-12-16 00:37:40 +00:00
$database = new Database(getenv("TEST_DSN") ?: "sqlite::memory:");
create_dirs();
create_tables($database);
$config = new DatabaseConfig($database);
2023-12-16 00:37:40 +00:00
_load_extension_files();
_load_theme_files();
$page = new Page();
_load_event_listeners();
2023-12-16 00:37:40 +00:00
$config->set_string("thumb_engine", "static");
$config->set_bool("nice_urls", true);
2020-01-27 19:52:54 +00:00
send_event(new DatabaseUpgradeEvent());
2020-01-27 19:05:43 +00:00
send_event(new InitExtEvent());
2023-02-24 21:08:05 +00:00
$user = User::by_id($config->get_int("anon_id", 0));
2024-01-15 22:50:43 +00:00
$userPage = new UserPage();
$userPage->onUserCreation(new UserCreationEvent("demo", "demo", "demo", "demo@demo.com", false));
$userPage->onUserCreation(new UserCreationEvent("test", "test", "test", "test@test.com", false));
$database->commit();
2020-01-28 23:57:43 +00:00
$_tracer->end();