-
-
Notifications
You must be signed in to change notification settings - Fork 257
/
Copy pathbootstrap.php
96 lines (79 loc) · 2.38 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Bootstrap phpMyFAQ PHPUnit testing environment
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*
* @package phpMyFAQ
* @author Thorsten Rinne <[email protected]>
* @copyright 2015 phpMyFAQ Team
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
* @link https://www.phpmyfaq.de
* @since 2015-02-12
*/
use Composer\Autoload\ClassLoader;
use phpMyFAQ\Setup\Installer;
use phpMyFAQ\Strings;
use phpMyFAQ\System;
use Symfony\Component\HttpFoundation\Request;
date_default_timezone_set('Europe/Berlin');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED);
//
// The root directory
//
define('PMF_ROOT_DIR', dirname(__DIR__) . '/phpmyfaq');
define('PMF_CONFIG_DIR', dirname(__DIR__) . '/tests/content/core/config');
define('PMF_CONTENT_DIR', dirname(__DIR__) . '/tests/content');
const PMF_LOG_DIR = __DIR__ . '/logs';
const PMF_TEST_DIR = __DIR__;
const IS_VALID_PHPMYFAQ = true;
const DEBUG = true;
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SERVER_NAME'] = 'localhost';
require PMF_ROOT_DIR . '/content/core/config/constants.php';
//
// The /src directory
//
define('PMF_SRC_DIR', dirname(__DIR__) . '/phpmyfaq/src');
//
// The directory where the translations reside
//
define('PMF_TRANSLATION_DIR', dirname(__DIR__) . '/phpmyfaq/translations');
require PMF_TRANSLATION_DIR . '/language_en.php';
//
// Setting up autoloader
//
$loader = new ClassLoader();
$loader->add('phpMyFAQ', PMF_SRC_DIR);
$loader->register();
//
// Delete a possible SQLite file first
//
@unlink(PMF_TEST_DIR . '/test.db');
//
// Create database credentials for SQLite
//
$setup = [
'dbServer' => PMF_TEST_DIR . '/test.db',
'dbType' => 'sqlite3',
'dbPort' => null,
'dbDatabaseName' => '',
'loginname' => 'admin',
'password' => 'password',
'password_retyped' => 'password',
'rootDir' => PMF_TEST_DIR,
'mainUrl' => 'https://localhost/',
];
Strings::init();
Request::setTrustedHosts(['^.*$']); // Trust all hosts for testing
try {
$installer = new Installer(new System());
$installer->startInstall($setup);
} catch (Exception $exception) {
echo $exception->getMessage();
}
require PMF_TEST_DIR . '/content/core/config/database.php';