1
0
Fork 0

Changing Friendica\App\Mode from static methods to public methods

- Changing from static methods to public methods
- Adding dev-composer-dependency Mockery for static method mocking (f.e. Config, DBA)
- Adding ModeTest with Mocking
- removing bootstrap from phpunit.xml because of double loading tests\bootstrap.php
This commit is contained in:
Philipp Holzer 2018-10-06 16:27:20 +02:00
commit 31148e25cf
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
21 changed files with 498 additions and 106 deletions

View file

@ -36,7 +36,7 @@ $a->backend = false;
require_once "include/dba.php";
// Missing DB connection: ERROR
if (App\Mode::has(App\Mode::LOCALCONFIGPRESENT) && !App\Mode::has(App\Mode::DBAVAILABLE)) {
if ($a->getMode()->has(App\Mode::LOCALCONFIGPRESENT) && !$a->getMode()->has(App\Mode::DBAVAILABLE)) {
System::httpExit(500, ['title' => 'Error 500 - Internal Server Error', 'description' => 'Apologies but the website is unavailable at the moment.']);
}
@ -48,7 +48,7 @@ if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
}
if (!App\Mode::isInstall()) {
if (!$a->getMode()->isInstall()) {
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
&& (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
&& (substr(System::baseUrl(), 0, 8) == "https://")
@ -107,7 +107,7 @@ if (!empty($_SESSION['language']) && $_SESSION['language'] !== $lang) {
L10n::loadTranslationTable($lang);
}
if (!empty($_GET['zrl']) && App\Mode::isNormal()) {
if (!empty($_GET['zrl']) && $a->getMode()->isNormal()) {
$a->query_string = Profile::stripZrls($a->query_string);
if (!local_user()) {
// Only continue when the given profile link seems valid
@ -130,7 +130,7 @@ if (!empty($_GET['zrl']) && App\Mode::isNormal()) {
}
}
if (!empty($_GET['owt']) && App\Mode::isNormal()) {
if (!empty($_GET['owt']) && $a->getMode()->isNormal()) {
$token = $_GET['owt'];
$a->query_string = Profile::stripQueryParam($a->query_string, 'owt');
Profile::openWebAuthInit($token);
@ -165,9 +165,9 @@ $_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
// in install mode, any url loads install module
// but we need "view" module for stylesheet
if (App\Mode::isInstall() && $a->module != 'view') {
if ($a->getMode()->isInstall() && $a->module != 'view') {
$a->module = 'install';
} elseif (!App\Mode::has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
} elseif (!$a->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $a->module != 'view') {
$a->module = 'maintenance';
} else {
check_url($a);
@ -320,7 +320,7 @@ if (file_exists($theme_info_file)) {
/* initialise content region */
if (App\Mode::isNormal()) {
if ($a->getMode()->isNormal()) {
Addon::callHooks('page_content_top', $a->page['content']);
}