diff --git a/init.php b/init.php index 4e56d291..6849d60c 100644 --- a/init.php +++ b/init.php @@ -1,6 +1,6 @@ main->mediaPath . DS . 'fonts'); $libPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'lib'); diff --git a/public_html/dispatch.php b/public_html/dispatch.php index 0c8ca3c2..89c0d394 100644 --- a/public_html/dispatch.php +++ b/public_html/dispatch.php @@ -2,12 +2,12 @@ require_once '../src/core.php'; $query = rtrim($_SERVER['REQUEST_URI'], '/'); -$context = getContext(); +$context = Core::getContext(); $context->query = $query; function renderView() { - $context = getContext(); + $context = Core::getContext(); \Chibi\View::render($context->layoutName, $context); } @@ -16,7 +16,7 @@ $context->simpleActionName = null; \Chibi\Router::setObserver(function($route, $args) { - $context = getContext(); + $context = Core::getContext(); $context->route = $route; list ($className, $methodName) = $route->destination; @@ -36,7 +36,7 @@ $context->simpleActionName = null; $context->simpleActionName); }); -Assets::setTitle($config->main->title); +Assets::setTitle(Core::getConfig()->main->title); $context->handleExceptions = false; $context->json = isset($_GET['json']); diff --git a/src/Access.php b/src/Access.php index d56c328a..86070e32 100644 --- a/src/Access.php +++ b/src/Access.php @@ -7,7 +7,7 @@ class Access public static function init() { self::$privileges = []; - foreach (getConfig()->privileges as $key => $minAccessRankName) + foreach (Core::getConfig()->privileges as $key => $minAccessRankName) { if (strpos($key, '.') === false) $key .= '.'; diff --git a/src/Api/Jobs/CommentJobs/AddCommentJob.php b/src/Api/Jobs/CommentJobs/AddCommentJob.php index 38e56fa4..dd38edb2 100644 --- a/src/Api/Jobs/CommentJobs/AddCommentJob.php +++ b/src/Api/Jobs/CommentJobs/AddCommentJob.php @@ -47,6 +47,6 @@ class AddCommentJob extends AbstractJob public function isConfirmedEmailRequired() { - return getConfig()->registration->needEmailForCommenting; + return Core::getConfig()->registration->needEmailForCommenting; } } diff --git a/src/Api/Jobs/CommentJobs/ListCommentsJob.php b/src/Api/Jobs/CommentJobs/ListCommentsJob.php index 1160c9d0..f4d52d25 100644 --- a/src/Api/Jobs/CommentJobs/ListCommentsJob.php +++ b/src/Api/Jobs/CommentJobs/ListCommentsJob.php @@ -6,7 +6,7 @@ class ListCommentsJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->comments->commentsPerPage); + $this->pager->setPageSize(Core::getConfig()->comments->commentsPerPage); } public function getPager() diff --git a/src/Api/Jobs/CommentJobs/PreviewCommentJob.php b/src/Api/Jobs/CommentJobs/PreviewCommentJob.php index 39695d1d..8718d3cd 100644 --- a/src/Api/Jobs/CommentJobs/PreviewCommentJob.php +++ b/src/Api/Jobs/CommentJobs/PreviewCommentJob.php @@ -53,6 +53,6 @@ class PreviewCommentJob extends AbstractJob public function isConfirmedEmailRequired() { - return getConfig()->registration->needEmailForCommenting; + return Core::getConfig()->registration->needEmailForCommenting; } } diff --git a/src/Api/Jobs/LogJobs/GetLogJob.php b/src/Api/Jobs/LogJobs/GetLogJob.php index 29ecf36d..a03e1b20 100644 --- a/src/Api/Jobs/LogJobs/GetLogJob.php +++ b/src/Api/Jobs/LogJobs/GetLogJob.php @@ -6,7 +6,7 @@ class GetLogJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->browsing->logsPerPage); + $this->pager->setPageSize(Core::getConfig()->browsing->logsPerPage); } public function getPager() @@ -26,7 +26,7 @@ class GetLogJob extends AbstractJob implements IPagedJob //parse input $page = max(1, intval($page)); $name = str_replace(['/', '\\'], '', $name); //paranoia mode - $path = TextHelper::absolutePath(dirname(getConfig()->main->logsPath) . DS . $name); + $path = TextHelper::absolutePath(dirname(Core::getConfig()->main->logsPath) . DS . $name); if (!file_exists($path)) throw new SimpleNotFoundException('Specified log doesn\'t exist'); diff --git a/src/Api/Jobs/LogJobs/ListLogsJob.php b/src/Api/Jobs/LogJobs/ListLogsJob.php index fe467f7e..19f38831 100644 --- a/src/Api/Jobs/LogJobs/ListLogsJob.php +++ b/src/Api/Jobs/LogJobs/ListLogsJob.php @@ -3,7 +3,7 @@ class ListLogsJob extends AbstractJob { public function execute() { - $path = TextHelper::absolutePath(getConfig()->main->logsPath); + $path = TextHelper::absolutePath(Core::getConfig()->main->logsPath); $logs = []; foreach (glob(dirname($path) . DS . '*.log') as $log) diff --git a/src/Api/Jobs/PostJobs/AddPostJob.php b/src/Api/Jobs/PostJobs/AddPostJob.php index 189a1793..7234bc1f 100644 --- a/src/Api/Jobs/PostJobs/AddPostJob.php +++ b/src/Api/Jobs/PostJobs/AddPostJob.php @@ -31,7 +31,7 @@ class AddPostJob extends AbstractJob PostModel::save($post); Logger::log('{user} added {post} (tags: {tags}, safety: {safety}, source: {source})', [ - 'user' => ($anonymous and !getConfig()->misc->logAnonymousUploads) + 'user' => ($anonymous and !Core::getConfig()->misc->logAnonymousUploads) ? TextHelper::reprUser(UserModel::getAnonymousName()) : TextHelper::reprUser(Auth::getCurrentUser()), 'post' => TextHelper::reprPost($post), @@ -56,6 +56,6 @@ class AddPostJob extends AbstractJob public function isConfirmedEmailRequired() { - return getConfig()->registration->needEmailForUploading; + return Core::getConfig()->registration->needEmailForUploading; } } diff --git a/src/Api/Jobs/PostJobs/GetPostContentJob.php b/src/Api/Jobs/PostJobs/GetPostContentJob.php index 271cd7fc..c138357e 100644 --- a/src/Api/Jobs/PostJobs/GetPostContentJob.php +++ b/src/Api/Jobs/PostJobs/GetPostContentJob.php @@ -11,7 +11,7 @@ class GetPostContentJob extends AbstractJob public function execute() { $post = $this->postRetriever->retrieve(); - $config = getConfig(); + $config = Core::getConfig(); $path = $post->tryGetWorkingFullPath(); if (!$path) diff --git a/src/Api/Jobs/PostJobs/GetPostThumbJob.php b/src/Api/Jobs/PostJobs/GetPostThumbJob.php index acde0132..22b94ba4 100644 --- a/src/Api/Jobs/PostJobs/GetPostThumbJob.php +++ b/src/Api/Jobs/PostJobs/GetPostThumbJob.php @@ -30,7 +30,7 @@ class GetPostThumbJob extends AbstractJob if (!$path) { - $path = getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'; + $path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'; $path = TextHelper::absolutePath($path); } } diff --git a/src/Api/Jobs/PostJobs/ListPostsJob.php b/src/Api/Jobs/PostJobs/ListPostsJob.php index dea4dd27..f5a21ec3 100644 --- a/src/Api/Jobs/PostJobs/ListPostsJob.php +++ b/src/Api/Jobs/PostJobs/ListPostsJob.php @@ -6,7 +6,7 @@ class ListPostsJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->browsing->postsPerPage); + $this->pager->setPageSize(Core::getConfig()->browsing->postsPerPage); } public function getPager() diff --git a/src/Api/Jobs/TagJobs/ListRelatedTagsJob.php b/src/Api/Jobs/TagJobs/ListRelatedTagsJob.php index 9dd99659..4478d4e7 100644 --- a/src/Api/Jobs/TagJobs/ListRelatedTagsJob.php +++ b/src/Api/Jobs/TagJobs/ListRelatedTagsJob.php @@ -6,7 +6,7 @@ class ListRelatedTagsJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->browsing->tagsRelated); + $this->pager->setPageSize(Core::getConfig()->browsing->tagsRelated); } public function getPager() diff --git a/src/Api/Jobs/TagJobs/ListTagsJob.php b/src/Api/Jobs/TagJobs/ListTagsJob.php index fa9bcc57..c3cead19 100644 --- a/src/Api/Jobs/TagJobs/ListTagsJob.php +++ b/src/Api/Jobs/TagJobs/ListTagsJob.php @@ -6,7 +6,7 @@ class ListTagsJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->browsing->tagsPerPage); + $this->pager->setPageSize(Core::getConfig()->browsing->tagsPerPage); } public function getPager() diff --git a/src/Api/Jobs/UserJobs/ActivateUserEmailJob.php b/src/Api/Jobs/UserJobs/ActivateUserEmailJob.php index f1746c11..5cf7ba4f 100644 --- a/src/Api/Jobs/UserJobs/ActivateUserEmailJob.php +++ b/src/Api/Jobs/UserJobs/ActivateUserEmailJob.php @@ -54,7 +54,7 @@ class ActivateUserEmailJob extends AbstractJob public static function sendEmail($user) { - $regConfig = getConfig()->registration; + $regConfig = Core::getConfig()->registration; if (!$regConfig->confirmationEmailEnabled) { diff --git a/src/Api/Jobs/UserJobs/EditUserEmailJob.php b/src/Api/Jobs/UserJobs/EditUserEmailJob.php index e1929eba..65b37a1e 100644 --- a/src/Api/Jobs/UserJobs/EditUserEmailJob.php +++ b/src/Api/Jobs/UserJobs/EditUserEmailJob.php @@ -10,7 +10,7 @@ class EditUserEmailJob extends AbstractJob public function execute() { - if (getConfig()->registration->needEmailForRegistering) + if (Core::getConfig()->registration->needEmailForRegistering) if (!$this->hasArgument(JobArgs::ARG_NEW_EMAIL) or empty($this->getArgument(JobArgs::ARG_NEW_EMAIL))) throw new SimpleException('E-mail address is required - you will be sent confirmation e-mail.'); diff --git a/src/Api/Jobs/UserJobs/ListUsersJob.php b/src/Api/Jobs/UserJobs/ListUsersJob.php index 8e5bb2f3..92b3da4b 100644 --- a/src/Api/Jobs/UserJobs/ListUsersJob.php +++ b/src/Api/Jobs/UserJobs/ListUsersJob.php @@ -6,7 +6,7 @@ class ListUsersJob extends AbstractJob implements IPagedJob public function __construct() { $this->pager = new JobPager($this); - $this->pager->setPageSize(getConfig()->browsing->usersPerPage); + $this->pager->setPageSize(Core::getConfig()->browsing->usersPerPage); } public function getPager() diff --git a/src/Api/Jobs/UserJobs/PasswordResetJob.php b/src/Api/Jobs/UserJobs/PasswordResetJob.php index ea943dfc..de531887 100644 --- a/src/Api/Jobs/UserJobs/PasswordResetJob.php +++ b/src/Api/Jobs/UserJobs/PasswordResetJob.php @@ -58,7 +58,7 @@ class PasswordResetJob extends AbstractJob public static function sendEmail($user) { - $regConfig = getConfig()->registration; + $regConfig = Core::getConfig()->registration; $mail = new Mail(); $mail->body = $regConfig->passwordResetEmailBody; diff --git a/src/Auth.php b/src/Auth.php index b503d950..2e99a90a 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -10,8 +10,8 @@ class Auth public static function login($name, $password, $remember) { - $config = getConfig(); - $context = getContext(); + $config = Core::getConfig(); + $context = Core::getContext(); $user = UserModel::tryGetByEmail($name); if ($user === null) diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index 27fd9ff6..35385003 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -10,7 +10,7 @@ class AuthController public function loginAction() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'auth-login'; $context->handleExceptions = true; @@ -33,7 +33,7 @@ class AuthController return; if (\Chibi\Util\Headers::getCode() != 200) return; - $context = getContext(); + $context = Core::getContext(); if ($context->simpleControllerName == 'auth') return; $_SESSION['login-redirect-url'] = $context->query; diff --git a/src/Controllers/CommentController.php b/src/Controllers/CommentController.php index c45e3c35..b4cea16f 100644 --- a/src/Controllers/CommentController.php +++ b/src/Controllers/CommentController.php @@ -9,7 +9,7 @@ class CommentController JobArgs::ARG_PAGE_NUMBER => $page, ]); - $context = getContext(); + $context = Core::getContext(); $context->transport->posts = $ret->entities; $context->transport->paginator = $ret; } @@ -25,7 +25,7 @@ class CommentController JobArgs::ARG_NEW_TEXT => InputHelper::get('text') ]); - getContext()->transport->textPreview = $comment->getTextMarkdown(); + Core::getContext()->transport->textPreview = $comment->getTextMarkdown(); } Api::run( @@ -38,7 +38,7 @@ class CommentController public function editView($id) { - getContext()->transport->comment = CommentModel::getById($id); + Core::getContext()->transport->comment = CommentModel::getById($id); } public function editAction($id) @@ -52,7 +52,7 @@ class CommentController JobArgs::ARG_NEW_TEXT => InputHelper::get('text') ]); - getContext()->transport->textPreview = $comment->getTextMarkdown(); + Core::getContext()->transport->textPreview = $comment->getTextMarkdown(); } Api::run( diff --git a/src/Controllers/LogController.php b/src/Controllers/LogController.php index 2be7c838..df93ca20 100644 --- a/src/Controllers/LogController.php +++ b/src/Controllers/LogController.php @@ -4,12 +4,12 @@ class LogController public function listView() { $ret = Api::run(new ListLogsJob(), []); - getContext()->transport->logs = $ret; + Core::getContext()->transport->logs = $ret; } public function logView($name, $page = 1, $filter = '') { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'log-view'; //redirect requests in form of ?query=... to canonical address diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 0444a874..ee8e4c35 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -3,7 +3,7 @@ class PostController { public function listView($query = null, $page = 1, $source = 'posts', $additionalInfo = null) { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'post-list-wrapper'; $context->source = $source; $context->additionalInfo = $additionalInfo; @@ -116,7 +116,7 @@ class PostController $post = Api::run(new GetPostJob(), [ JobArgs::ARG_POST_ID => $id]); - $context = getContext()->transport->post = $post; + $context = Core::getContext()->transport->post = $post; } public function editAction($id) @@ -217,7 +217,7 @@ class PostController public function genericView($id) { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'post-view'; $post = Api::run(new GetPostJob(), [ @@ -257,7 +257,7 @@ class PostController { $ret = Api::run(new GetPostContentJob(), [JobArgs::ARG_POST_NAME => $name]); - $context = getContext(); + $context = Core::getContext(); $context->transport->cacheDaysToLive = 14; $context->transport->customFileName = $ret->fileName; $context->transport->mimeType = $ret->mimeType; @@ -271,7 +271,7 @@ class PostController { $ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]); - $context = getContext(); + $context = Core::getContext(); $context->transport->cacheDaysToLive = 365; $context->transport->customFileName = $ret->fileName; $context->transport->mimeType = 'image/jpeg'; diff --git a/src/Controllers/StaticPagesController.php b/src/Controllers/StaticPagesController.php index 1b721264..38e1cd45 100644 --- a/src/Controllers/StaticPagesController.php +++ b/src/Controllers/StaticPagesController.php @@ -3,7 +3,7 @@ class StaticPagesController { public function mainPageView() { - $context = getContext(); + $context = Core::getContext(); $context->transport->postCount = PostModel::getCount(); $context->viewName = 'static-main'; $context->transport->postSpaceUsage = PostModel::getSpaceUsage(); @@ -21,8 +21,8 @@ class StaticPagesController public function helpView($tab = null) { - $config = getConfig(); - $context = getContext(); + $config = Core::getConfig(); + $context = Core::getContext(); if (empty($config->help->paths) or empty($config->help->title)) throw new SimpleException('Help is disabled'); diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php index 7faca0f2..63cf4882 100644 --- a/src/Controllers/TagController.php +++ b/src/Controllers/TagController.php @@ -10,7 +10,7 @@ class TagController JobArgs::ARG_QUERY => $filter, ]); - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; $context->highestUsage = TagSearchService::getMostUsedTag()->getPostCount(); $context->filter = $filter; @@ -30,7 +30,7 @@ class TagController JobArgs::ARG_PAGE_NUMBER => 1, ]); - $context = getContext(); + $context = Core::getContext(); $context->transport->tags = array_values(array_map( function($tag) @@ -55,7 +55,7 @@ class TagController JobArgs::ARG_PAGE_NUMBER => 1 ]); - $context = getContext(); + $context = Core::getContext(); $context->transport->tags = array_values(array_map( function($tag) @@ -69,13 +69,13 @@ class TagController public function mergeView() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; } public function mergeAction() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; $context->handleExceptions = true; @@ -91,13 +91,13 @@ class TagController public function renameView() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; } public function renameAction() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; $context->handleExceptions = true; @@ -113,7 +113,7 @@ class TagController public function massTagRedirectView() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'tag-list-wrapper'; Access::assert(new Privilege(Privilege::MassTag)); diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 8df275d2..f89a6608 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -10,7 +10,7 @@ class UserController JobArgs::ARG_QUERY => $filter, ]); - $context = getContext(); + $context = Core::getContext(); $context->filter = $filter; $context->transport->users = $ret->entities; @@ -45,7 +45,7 @@ class UserController elseif ($tab == 'edit' and !(new EditUserJob)->canEditAnything(Auth::getCurrentUser())) Access::fail(); - $context = getContext(); + $context = Core::getContext(); $context->flagged = $flagged; $context->transport->tab = $tab; $context->transport->user = $user; @@ -87,7 +87,7 @@ class UserController ] ], $identifier)); - getContext()->transport->user = $user; + Core::getContext()->transport->user = $user; if ($user->getId() == Auth::getCurrentUser()->getId()) Auth::setCurrentUser($user); @@ -194,7 +194,7 @@ class UserController public function registrationView() { - $context = getContext(); + $context = Core::getContext(); $context->handleExceptions = true; //check if already logged in @@ -219,7 +219,7 @@ class UserController JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'), ]); - if (!getConfig()->registration->needEmailForRegistering and !getConfig()->registration->staffActivation) + if (!Core::getConfig()->registration->needEmailForRegistering and !Core::getConfig()->registration->staffActivation) { Auth::setCurrentUser($user); } @@ -228,10 +228,10 @@ class UserController if (Mailer::getMailCounter() > 0) { $message .= ' Please wait for activation e-mail.'; - if (getConfig()->registration->staffActivation) + if (Core::getConfig()->registration->staffActivation) $message .= ' After this, your registration must be confirmed by staff.'; } - elseif (getConfig()->registration->staffActivation) + elseif (Core::getConfig()->registration->staffActivation) $message .= ' Your registration must be now confirmed by staff.'; Messenger::message($message); @@ -239,14 +239,14 @@ class UserController public function activationView() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'user-select'; Assets::setSubTitle('account activation'); } public function activationAction($tokenText) { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'message'; Assets::setSubTitle('account activation'); $identifier = InputHelper::get('identifier'); @@ -265,25 +265,25 @@ class UserController JobArgs::ARG_TOKEN => $tokenText ]); $message = 'Activation completed successfully.'; - if (getConfig()->registration->staffActivation) + if (Core::getConfig()->registration->staffActivation) $message .= ' However, your account still must be confirmed by staff.'; Messenger::message($message); - if (!getConfig()->registration->staffActivation) + if (!Core::getConfig()->registration->staffActivation) Auth::setCurrentUser($user); } } public function passwordResetView() { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'user-select'; Assets::setSubTitle('password reset'); } public function passwordResetAction($tokenText) { - $context = getContext(); + $context = Core::getContext(); $context->viewName = 'message'; Assets::setSubTitle('password reset'); $identifier = InputHelper::get('identifier'); @@ -310,7 +310,7 @@ class UserController private function requirePasswordConfirmation() { - $user = getContext()->transport->user; + $user = Core::getContext()->transport->user; if (Auth::getCurrentUser()->getId() == $user->getId()) { $suppliedPassword = InputHelper::get('current-password'); diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php index 3c63bd0f..760cd7a9 100644 --- a/src/Helpers/TextHelper.php +++ b/src/Helpers/TextHelper.php @@ -220,7 +220,7 @@ class TextHelper public static function encrypt($text) { - $salt = getConfig()->main->salt; + $salt = Core::getConfig()->main->salt; $alg = MCRYPT_RIJNDAEL_256; $mode = MCRYPT_MODE_CBC; $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, $mode), MCRYPT_RAND); @@ -231,7 +231,7 @@ class TextHelper { try { - $salt = getConfig()->main->salt; + $salt = Core::getConfig()->main->salt; list ($iv, $hash) = explode('|', $text, 2); $iv = base64_decode($iv); $hash = base64_decode($hash); @@ -262,7 +262,7 @@ class TextHelper public static function absolutePath($path) { if ($path{0} != DS) - $path = getConfig()->rootDir . DS . $path; + $path = Core::getConfig()->rootDir . DS . $path; $path = self::cleanPath($path); return $path; diff --git a/src/Helpers/ThumbnailHelper.php b/src/Helpers/ThumbnailHelper.php index 1e3358f0..53a38b36 100644 --- a/src/Helpers/ThumbnailHelper.php +++ b/src/Helpers/ThumbnailHelper.php @@ -145,7 +145,7 @@ class ThumbnailHelper throw new SimpleException('Invalid thumbnail file type'); } - $config = getConfig(); + $config = Core::getConfig(); switch ($config->browsing->thumbStyle) { case 'outside': diff --git a/src/Logger.php b/src/Logger.php index 465eba33..0b3ca8db 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -51,7 +51,7 @@ class Logger public static function getLogPath() { return TextHelper::absolutePath( - TextHelper::replaceTokens(getConfig()->main->logsPath, [ + TextHelper::replaceTokens(Core::getConfig()->main->logsPath, [ 'yyyy' => date('Y'), 'mm' => date('m'), 'dd' => date('d')])); diff --git a/src/Messenger.php b/src/Messenger.php index 156dcba6..bd7c5cbd 100644 --- a/src/Messenger.php +++ b/src/Messenger.php @@ -6,7 +6,7 @@ class Messenger if (empty($message)) return; - $context = getContext(); + $context = Core::getContext(); if (!preg_match('/[.?!]$/', $message)) $message .= '.'; diff --git a/src/Models/Entities/CommentEntity.php b/src/Models/Entities/CommentEntity.php index f8d25c27..cd99598d 100644 --- a/src/Models/Entities/CommentEntity.php +++ b/src/Models/Entities/CommentEntity.php @@ -22,7 +22,7 @@ final class CommentEntity extends AbstractEntity implements IValidatable public function validate() { - $config = getConfig(); + $config = Core::getConfig(); if (strlen($this->getText()) < $config->comments->minLength) throw new SimpleException('Comment must have at least %d characters', $config->comments->minLength); diff --git a/src/Models/Entities/PostEntity.php b/src/Models/Entities/PostEntity.php index a0530fc0..656d3eda 100644 --- a/src/Models/Entities/PostEntity.php +++ b/src/Models/Entities/PostEntity.php @@ -66,7 +66,7 @@ final class PostEntity extends AbstractEntity implements IValidatable $this->getSafety()->validate(); - $maxSourceLength = getConfig()->posts->maxSourceLength; + $maxSourceLength = Core::getConfig()->posts->maxSourceLength; if (strlen($this->getSource()) > $maxSourceLength) throw new SimpleException('Source must have at most %d characters', $maxSourceLength); } @@ -351,7 +351,7 @@ final class PostEntity extends AbstractEntity implements IValidatable public function setCustomThumbnailFromPath($srcPath) { - $config = getConfig(); + $config = Core::getConfig(); $mimeType = mime_content_type($srcPath); if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg'])) @@ -366,8 +366,8 @@ final class PostEntity extends AbstractEntity implements IValidatable public function generateThumb() { - $width = getConfig()->browsing->thumbWidth; - $height = getConfig()->browsing->thumbHeight; + $width = Core::getConfig()->browsing->thumbWidth; + $height = Core::getConfig()->browsing->thumbHeight; $dstPath = $this->getThumbPath($width, $height); if (file_exists($this->getThumbCustomSourcePath())) diff --git a/src/Models/Entities/TagEntity.php b/src/Models/Entities/TagEntity.php index ea383fc4..a40f1662 100644 --- a/src/Models/Entities/TagEntity.php +++ b/src/Models/Entities/TagEntity.php @@ -21,9 +21,9 @@ final class TagEntity extends AbstractEntity implements IValidatable public function validate() { - $minLength = getConfig()->tags->minLength; - $maxLength = getConfig()->tags->maxLength; - $regex = getConfig()->tags->regex; + $minLength = Core::getConfig()->tags->minLength; + $maxLength = Core::getConfig()->tags->maxLength; + $regex = Core::getConfig()->tags->regex; $name = $this->getName(); diff --git a/src/Models/Entities/UserEntity.php b/src/Models/Entities/UserEntity.php index e552314a..b09e5ea2 100644 --- a/src/Models/Entities/UserEntity.php +++ b/src/Models/Entities/UserEntity.php @@ -60,7 +60,7 @@ final class UserEntity extends AbstractEntity implements IValidatable private function validateUserName() { $userName = $this->getName(); - $config = getConfig(); + $config = Core::getConfig(); $otherUser = UserModel::tryGetByName($userName); if ($otherUser !== null and $otherUser->getId() != $this->getId()) @@ -90,7 +90,7 @@ final class UserEntity extends AbstractEntity implements IValidatable if (!$this->_passwordChanged) return; - $config = getConfig(); + $config = Core::getConfig(); $passMinLength = intval($config->registration->passMinLength); $passRegex = $config->registration->passRegex; @@ -131,7 +131,7 @@ final class UserEntity extends AbstractEntity implements IValidatable private function throwDuplicateUserError($otherUser, $reason) { - $config = getConfig(); + $config = Core::getConfig(); if (!$otherUser->getConfirmedEmail() and isset($config->registration->needEmailForRegistering) diff --git a/src/Models/PostModel.php b/src/Models/PostModel.php index bc85c6f5..a0d0d940 100644 --- a/src/Models/PostModel.php +++ b/src/Models/PostModel.php @@ -277,7 +277,7 @@ final class PostModel extends AbstractCrudModel private static function getThumbPathTokenized($text, $name) { return TextHelper::absolutePath(TextHelper::replaceTokens($text, [ - 'fullpath' => getConfig()->main->thumbsPath . DS . $name])); + 'fullpath' => Core::getConfig()->main->thumbsPath . DS . $name])); } public static function tryGetWorkingFullPath($name) @@ -291,7 +291,7 @@ final class PostModel extends AbstractCrudModel public static function getFullPath($name) { - return TextHelper::absolutePath(getConfig()->main->filesPath . DS . $name); + return TextHelper::absolutePath(Core::getConfig()->main->filesPath . DS . $name); } @@ -303,7 +303,7 @@ final class PostModel extends AbstractCrudModel return PropertyModel::get(PropertyModel::PostSpaceUsage); $totalBytes = 0; - $paths = [getConfig()->main->filesPath, getConfig()->main->thumbsPath]; + $paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbsPath]; foreach ($paths as $path) { @@ -332,7 +332,7 @@ final class PostModel extends AbstractCrudModel public static function featureRandomPostIfNecessary() { - $config = getConfig(); + $config = Core::getConfig(); $featuredPostRotationTime = $config->misc->featuredPostMaxDays * 24 * 3600; $featuredPostId = PropertyModel::get(PropertyModel::FeaturedPostId); diff --git a/src/Models/SearchParsers/PostSearchParser.php b/src/Models/SearchParsers/PostSearchParser.php index fceab77d..97821fc6 100644 --- a/src/Models/SearchParsers/PostSearchParser.php +++ b/src/Models/SearchParsers/PostSearchParser.php @@ -9,7 +9,7 @@ class PostSearchParser extends AbstractSearchParser protected function processSetup(&$tokens) { - $config = getConfig(); + $config = Core::getConfig(); $this->tags = []; $crit = new Sql\ConjunctionFunctor(); diff --git a/src/Models/UserModel.php b/src/Models/UserModel.php index 7d8eb137..00dbccd9 100644 --- a/src/Models/UserModel.php +++ b/src/Models/UserModel.php @@ -188,7 +188,7 @@ final class UserModel extends AbstractCrudModel public static function hashPassword($pass, $salt2) { - $salt1 = getConfig()->main->salt; + $salt1 = Core::getConfig()->main->salt; return sha1($salt1 . $salt2 . $pass); } } diff --git a/src/Models/UserSettings.php b/src/Models/UserSettings.php index 462f279c..9ee47dfd 100644 --- a/src/Models/UserSettings.php +++ b/src/Models/UserSettings.php @@ -111,13 +111,13 @@ class UserSettings implements IValidatable $this->set(self::SETTING_SAFETY, (new PostSafety(PostSafety::Safe))->toInteger()); if ($this->get(self::SETTING_HIDE_DISLIKED_POSTS) === null) - $this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) getConfig()->browsing->showDislikedPostsDefault); + $this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) Core::getConfig()->browsing->showDislikedPostsDefault); if ($this->get(self::SETTING_POST_TAG_TITLES) === null) - $this->set(self::SETTING_POST_TAG_TITLES, (bool) getConfig()->browsing->showPostTagTitlesDefault); + $this->set(self::SETTING_POST_TAG_TITLES, (bool) Core::getConfig()->browsing->showPostTagTitlesDefault); if ($this->get(self::SETTING_ENDLESS_SCROLLING) === null) - $this->set(self::SETTING_ENDLESS_SCROLLING, (bool) getConfig()->browsing->endlessScrollingDefault); + $this->set(self::SETTING_ENDLESS_SCROLLING, (bool) Core::getConfig()->browsing->endlessScrollingDefault); } private function ensureCorrectTypes() diff --git a/src/Views/comment-list.phtml b/src/Views/comment-list.phtml index ac29ca1b..a7a040a7 100644 --- a/src/Views/comment-list.phtml +++ b/src/Views/comment-list.phtml @@ -20,7 +20,7 @@ Assets::setSubTitle('comments'); context->post = $post; $comments = array_reverse($post->getComments()); - $commentsToDisplay = array_slice($comments, 0, getConfig()->comments->maxCommentsInList); + $commentsToDisplay = array_slice($comments, 0, Core::getConfig()->comments->maxCommentsInList); ?> context) ?> diff --git a/src/Views/layout-normal.phtml b/src/Views/layout-normal.phtml index 5162c8b2..33f3f634 100644 --- a/src/Views/layout-normal.phtml +++ b/src/Views/layout-normal.phtml @@ -41,7 +41,7 @@ Assets::addScript('core.js');
help->title)) + if (!empty(Core::getConfig()->help->title)) { $registerNavItem( - getConfig()->help->title, + Core::getConfig()->help->title, \Chibi\Router::linkTo(['StaticPagesController', 'helpView']), $activeController == 'static-pages' and $activeAction == 'help'); } diff --git a/src/Views/user-list.phtml b/src/Views/user-list.phtml index 13899dfd..6961c683 100644 --- a/src/Views/user-list.phtml +++ b/src/Views/user-list.phtml @@ -14,7 +14,7 @@ Assets::addStylesheet('user-list.css'); 'order:date,desc' => 'Sort new→old', ]; - if (getConfig()->registration->staffActivation) + if (Core::getConfig()->registration->staffActivation) $filters['pending'] = 'Pending staff review'; ?> diff --git a/src/Views/user-view.phtml b/src/Views/user-view.phtml index 158f6f22..a5d2b6e5 100644 --- a/src/Views/user-view.phtml +++ b/src/Views/user-view.phtml @@ -104,7 +104,7 @@ Assets::addStylesheet('user-view.css'); if (Access::check(new Privilege(Privilege::AcceptUserRegistration)) and !$this->context->transport->user->isStaffConfirmed() - and getConfig()->registration->staffActivation) + and Core::getConfig()->registration->staffActivation) { $options []= [ diff --git a/src/core.php b/src/core.php index 8caed07a..85be5039 100644 --- a/src/core.php +++ b/src/core.php @@ -37,7 +37,6 @@ final class Core static function prepareConfig($testEnvironment) { //load config manually - global $config; global $rootDir; $configPaths = []; @@ -178,16 +177,5 @@ final class Core } } -//legacy -function getConfig() -{ - return Core::getConfig(); -} - -function getContext() -{ - return Core::getContext(); -} - Core::prepareConfig(false); Core::prepareEnvironment(false); diff --git a/tests/Support/TestSupport.php b/tests/Support/TestSupport.php index 271d8e99..0063f4c5 100644 --- a/tests/Support/TestSupport.php +++ b/tests/Support/TestSupport.php @@ -10,7 +10,7 @@ class TestSupport public function getPath($assetName) { - return TextHelper::absolutePath(getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName); + return TextHelper::absolutePath(Core::getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName); } public function assertTagNames($post, $tags) diff --git a/tests/Tests/AbstractFullApiTest.php b/tests/Tests/AbstractFullApiTest.php index cefb6aa2..a3389dd9 100644 --- a/tests/Tests/AbstractFullApiTest.php +++ b/tests/Tests/AbstractFullApiTest.php @@ -19,7 +19,7 @@ abstract class AbstractFullApiTest extends AbstractTest protected function getAllJobs() { - $pathToJobs = getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs'; + $pathToJobs = Core::getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs'; $directory = new RecursiveDirectoryIterator($pathToJobs); $iterator = new RecursiveIteratorIterator($directory); $regex = new RegexIterator($iterator, '/^.+Job\.php$/i'); diff --git a/tests/Tests/AbstractTest.php b/tests/Tests/AbstractTest.php index 8249d3f4..e2e65dbd 100644 --- a/tests/Tests/AbstractTest.php +++ b/tests/Tests/AbstractTest.php @@ -33,13 +33,13 @@ class AbstractTest protected function grantAccess($privilege) { - getConfig()->privileges->$privilege = 'anonymous'; + Core::getConfig()->privileges->$privilege = 'anonymous'; Access::init(); } protected function revokeAccess($privilege) { - getConfig()->privileges->$privilege = 'nobody'; + Core::getConfig()->privileges->$privilege = 'nobody'; Access::init(); } } diff --git a/tests/Tests/ApiTests/ApiAuthTest.php b/tests/Tests/ApiTests/ApiAuthTest.php index ee6f958f..fa1fe2c6 100644 --- a/tests/Tests/ApiTests/ApiAuthTest.php +++ b/tests/Tests/ApiTests/ApiAuthTest.php @@ -60,7 +60,7 @@ class ApiAuthTest extends AbstractFullApiTest public function testAuthEnforcing() { - getConfig()->registration->needEmailForCommenting = false; + Core::getConfig()->registration->needEmailForCommenting = false; $this->grantAccess('addComment'); $comment = $this->commentMocker->mockSingle(); diff --git a/tests/Tests/ApiTests/ApiEmailRequirementsTest.php b/tests/Tests/ApiTests/ApiEmailRequirementsTest.php index 8aceb739..ab9b8e32 100644 --- a/tests/Tests/ApiTests/ApiEmailRequirementsTest.php +++ b/tests/Tests/ApiTests/ApiEmailRequirementsTest.php @@ -3,8 +3,8 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest { public function testRegularEmailRequirements() { - getConfig()->registration->needEmailForCommenting = true; - getConfig()->registration->needEmailForUploading = true; + Core::getConfig()->registration->needEmailForCommenting = true; + Core::getConfig()->registration->needEmailForUploading = true; $this->testRegularEmailRequirement(new AcceptUserRegistrationJob()); $this->testRegularEmailRequirement(new ActivateUserEmailJob()); @@ -68,10 +68,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest { $this->testedJobs []= $job; - getConfig()->registration->needEmailForCommenting = false; + Core::getConfig()->registration->needEmailForCommenting = false; $this->assert->areEqual(false, $job->isConfirmedEmailRequired()); - getConfig()->registration->needEmailForCommenting = true; + Core::getConfig()->registration->needEmailForCommenting = true; $this->assert->areEqual(true, $job->isConfirmedEmailRequired()); } @@ -81,10 +81,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest $this->testedJobs []= $job; - getConfig()->registration->needEmailForUploading = false; + Core::getConfig()->registration->needEmailForUploading = false; $this->assert->areEqual(false, $job->isConfirmedEmailRequired()); - getConfig()->registration->needEmailForUploading = true; + Core::getConfig()->registration->needEmailForUploading = true; $this->assert->areEqual(true, $job->isConfirmedEmailRequired()); } @@ -92,7 +92,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest { $this->grantAccess('addComment'); $this->login($this->userMocker->mockSingle()); - getConfig()->registration->needEmailForCommenting = true; + Core::getConfig()->registration->needEmailForCommenting = true; $this->assert->throws(function() { $post = $this->postMocker->mockSingle(); diff --git a/tests/Tests/ApiTests/ApiPrivilegeTest.php b/tests/Tests/ApiTests/ApiPrivilegeTest.php index acbd8258..a286ccb5 100644 --- a/tests/Tests/ApiTests/ApiPrivilegeTest.php +++ b/tests/Tests/ApiTests/ApiPrivilegeTest.php @@ -195,7 +195,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest $this->assert->throws(function() { $post = $this->postMocker->mockSingle(); - getConfig()->registration->needEmailForCommenting = false; + Core::getConfig()->registration->needEmailForCommenting = false; return Api::run( new AddCommentJob(), [ diff --git a/tests/Tests/JobTests/ActivateUserEmailJobTest.php b/tests/Tests/JobTests/ActivateUserEmailJobTest.php index ed5cbf49..2a44b6db 100644 --- a/tests/Tests/JobTests/ActivateUserEmailJobTest.php +++ b/tests/Tests/JobTests/ActivateUserEmailJobTest.php @@ -3,7 +3,7 @@ class ActivateUserEmailJobTest extends AbstractTest { public function testSending() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); @@ -35,7 +35,7 @@ class ActivateUserEmailJobTest extends AbstractTest public function testConfirming() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); @@ -74,7 +74,7 @@ class ActivateUserEmailJobTest extends AbstractTest public function testUsingTokenTwice() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); diff --git a/tests/Tests/JobTests/AddCommentJobTest.php b/tests/Tests/JobTests/AddCommentJobTest.php index d1f54aea..57de2799 100644 --- a/tests/Tests/JobTests/AddCommentJobTest.php +++ b/tests/Tests/JobTests/AddCommentJobTest.php @@ -31,7 +31,7 @@ class AddCommentJobTest extends AbstractTest $this->prepare(); $this->assert->doesNotThrow(function() { - $this->runApi(str_repeat('b', getConfig()->comments->minLength)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength)); }); } @@ -40,7 +40,7 @@ class AddCommentJobTest extends AbstractTest $this->prepare(); $this->assert->doesNotThrow(function() { - $this->runApi(str_repeat('b', getConfig()->comments->maxLength)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength)); }); } @@ -49,7 +49,7 @@ class AddCommentJobTest extends AbstractTest $this->prepare(); $this->assert->throws(function() { - $this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1)); }, 'Comment must have at least'); } @@ -58,7 +58,7 @@ class AddCommentJobTest extends AbstractTest $this->prepare(); $this->assert->throws(function() { - $this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1)); }, 'Comment must have at most'); } @@ -109,7 +109,7 @@ class AddCommentJobTest extends AbstractTest protected function prepare() { - getConfig()->registration->needEmailForCommenting = false; + Core::getConfig()->registration->needEmailForCommenting = false; $this->grantAccess('addComment'); $this->login($this->userMocker->mockSingle()); } diff --git a/tests/Tests/JobTests/AddPostJobTest.php b/tests/Tests/JobTests/AddPostJobTest.php index 5029111a..53745252 100644 --- a/tests/Tests/JobTests/AddPostJobTest.php +++ b/tests/Tests/JobTests/AddPostJobTest.php @@ -154,6 +154,6 @@ class AddPostJobTest extends AbstractTest protected function prepare() { - getConfig()->registration->needEmailForUploading = false; + Core::getConfig()->registration->needEmailForUploading = false; } } diff --git a/tests/Tests/JobTests/AddUserJobTest.php b/tests/Tests/JobTests/AddUserJobTest.php index 2ef0e7bc..e747f9f2 100644 --- a/tests/Tests/JobTests/AddUserJobTest.php +++ b/tests/Tests/JobTests/AddUserJobTest.php @@ -45,14 +45,14 @@ class AddUserJobTest extends AbstractTest new AddUserJob(), [ JobArgs::ARG_NEW_USER_NAME => 'dummy', - JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1), + JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1), ]); }, 'Password must have at least'); } public function testSkippingMailingUponFailing() //yo dog { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); @@ -64,7 +64,7 @@ class AddUserJobTest extends AbstractTest new AddUserJob(), [ JobArgs::ARG_NEW_USER_NAME => 'dummy', - JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1), + JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1), JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov', ]); }, 'Password must have at least'); @@ -89,7 +89,7 @@ class AddUserJobTest extends AbstractTest $this->assert->isTrue(strlen($user->getPasswordHash()) < 100); - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; $this->assert->doesNotThrow(function() use ($pass) { Auth::login('dummy', $pass, false); @@ -143,11 +143,11 @@ class AddUserJobTest extends AbstractTest public function testEmailsMixedConfirmation() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; $this->grantAccess('registerAccount'); $user1 = $this->assert->doesNotThrow(function() @@ -185,11 +185,11 @@ class AddUserJobTest extends AbstractTest public function testEmailsEveryoneMustConfirm() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; $this->grantAccess('registerAccount'); $user1 = $this->assert->doesNotThrow(function() @@ -225,11 +225,11 @@ class AddUserJobTest extends AbstractTest public function testEmailsEveryoneSkipConfirm() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; $this->grantAccess('registerAccount'); $user1 = $this->assert->doesNotThrow(function() @@ -265,7 +265,7 @@ class AddUserJobTest extends AbstractTest public function testEmailsTwoUsersSameMail() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); diff --git a/tests/Tests/JobTests/EditCommentJobTest.php b/tests/Tests/JobTests/EditCommentJobTest.php index cf0b6286..897621a4 100644 --- a/tests/Tests/JobTests/EditCommentJobTest.php +++ b/tests/Tests/JobTests/EditCommentJobTest.php @@ -28,7 +28,7 @@ class EditCommentJobTest extends AbstractTest $this->grantAccess('editComment.own'); $this->assert->doesNotThrow(function() { - $this->runApi(str_repeat('b', getConfig()->comments->minLength)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength)); }); } @@ -38,7 +38,7 @@ class EditCommentJobTest extends AbstractTest $this->grantAccess('editComment.own'); $this->assert->doesNotThrow(function() { - $this->runApi(str_repeat('b', getConfig()->comments->maxLength)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength)); }); } @@ -48,7 +48,7 @@ class EditCommentJobTest extends AbstractTest $this->grantAccess('editComment.own'); $this->assert->throws(function() { - $this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1)); }, 'Comment must have at least'); } @@ -58,7 +58,7 @@ class EditCommentJobTest extends AbstractTest $this->grantAccess('editComment.own'); $this->assert->throws(function() { - $this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); + $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1)); }, 'Comment must have at most'); } diff --git a/tests/Tests/JobTests/EditPostSourceJobTest.php b/tests/Tests/JobTests/EditPostSourceJobTest.php index 7fd67112..2ecd270b 100644 --- a/tests/Tests/JobTests/EditPostSourceJobTest.php +++ b/tests/Tests/JobTests/EditPostSourceJobTest.php @@ -23,7 +23,7 @@ class EditPostSourceJobTest extends AbstractTest $this->grantAccess('editPostSource.own'); $this->assert->doesNotThrow(function() { - $this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength)); + $this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength)); }); } @@ -33,7 +33,7 @@ class EditPostSourceJobTest extends AbstractTest $this->grantAccess('editPostSource.own'); $this->assert->throws(function() { - $this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength + 1)); + $this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength + 1)); }, 'Source must have at most'); } diff --git a/tests/Tests/JobTests/EditPostTagsJobTest.php b/tests/Tests/JobTests/EditPostTagsJobTest.php index 3c5a761f..f67745f1 100644 --- a/tests/Tests/JobTests/EditPostTagsJobTest.php +++ b/tests/Tests/JobTests/EditPostTagsJobTest.php @@ -49,7 +49,7 @@ class EditPostTagsJobTest extends AbstractTest $post = $this->postMocker->mockSingle(); $this->grantAccess('editPostTags'); - $newTagNames = [str_repeat('u', getConfig()->tags->minLength - 1)]; + $newTagNames = [str_repeat('u', Core::getConfig()->tags->minLength - 1)]; $this->assert->throws(function() use ($post, $newTagNames) { Api::run( @@ -66,7 +66,7 @@ class EditPostTagsJobTest extends AbstractTest $post = $this->postMocker->mockSingle(); $this->grantAccess('editPostTags'); - $newTagNames = [str_repeat('u', getConfig()->tags->maxLength + 1)]; + $newTagNames = [str_repeat('u', Core::getConfig()->tags->maxLength + 1)]; $this->assert->throws(function() use ($post, $newTagNames) { Api::run( diff --git a/tests/Tests/JobTests/EditUserAccessRankJobTest.php b/tests/Tests/JobTests/EditUserAccessRankJobTest.php index 63cc0bcb..dc640789 100644 --- a/tests/Tests/JobTests/EditUserAccessRankJobTest.php +++ b/tests/Tests/JobTests/EditUserAccessRankJobTest.php @@ -41,7 +41,7 @@ class EditUserAccessRankJobTest extends AbstractTest public function testHigherThanMyselfDenial() { - getConfig()->privileges->changeUserAccessRank = 'power-user'; + Core::getConfig()->privileges->changeUserAccessRank = 'power-user'; Access::init(); $user = $this->userMocker->mockSingle(); diff --git a/tests/Tests/JobTests/EditUserEmailJobTest.php b/tests/Tests/JobTests/EditUserEmailJobTest.php index 41049dba..f5d1c1ba 100644 --- a/tests/Tests/JobTests/EditUserEmailJobTest.php +++ b/tests/Tests/JobTests/EditUserEmailJobTest.php @@ -3,11 +3,11 @@ class EditUserEmailJobTest extends AbstractTest { public function testNoConfirmation() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; $this->grantAccess('changeUserEmail'); $user = $this->userMocker->mockSingle(); @@ -30,11 +30,11 @@ class EditUserEmailJobTest extends AbstractTest public function testConfirmation() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; $this->grantAccess('changeUserEmail'); $user = $this->userMocker->mockSingle(); @@ -57,10 +57,10 @@ class EditUserEmailJobTest extends AbstractTest public function testInvalidEmail() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; Mailer::mockSending(); - getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; $this->grantAccess('changeUserEmail'); $user = $this->userMocker->mockSingle(); @@ -78,11 +78,11 @@ class EditUserEmailJobTest extends AbstractTest public function testChangingToExistingDenial() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; Mailer::mockSending(); $this->assert->areEqual(0, Mailer::getMailCounter()); - getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; + Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; $this->grantAccess('changeUserEmail'); list ($user, $otherUser) diff --git a/tests/Tests/JobTests/EditUserNameJobTest.php b/tests/Tests/JobTests/EditUserNameJobTest.php index ff646b62..5ed42250 100644 --- a/tests/Tests/JobTests/EditUserNameJobTest.php +++ b/tests/Tests/JobTests/EditUserNameJobTest.php @@ -28,7 +28,7 @@ class EditUserNameJobTest extends AbstractTest $this->grantAccess('changeUserName'); $user = $this->userMocker->mockSingle(); - $newName = str_repeat('a', getConfig()->registration->userNameMinLength - 1); + $newName = str_repeat('a', Core::getConfig()->registration->userNameMinLength - 1); $this->assert->throws(function() use ($user, $newName) { @@ -46,7 +46,7 @@ class EditUserNameJobTest extends AbstractTest $this->grantAccess('changeUserName'); $user = $this->userMocker->mockSingle(); - $newName = str_repeat('a', getConfig()->registration->userNameMaxLength + 1); + $newName = str_repeat('a', Core::getConfig()->registration->userNameMaxLength + 1); $this->assert->throws(function() use ($user, $newName) { diff --git a/tests/Tests/JobTests/EditUserPasswordJobTest.php b/tests/Tests/JobTests/EditUserPasswordJobTest.php index 9650b374..cc718de9 100644 --- a/tests/Tests/JobTests/EditUserPasswordJobTest.php +++ b/tests/Tests/JobTests/EditUserPasswordJobTest.php @@ -16,7 +16,7 @@ class EditUserPasswordJobTest extends AbstractTest $this->grantAccess('changeUserPassword'); $user = $this->userMocker->mockSingle(); - $newPassword = str_repeat('a', getConfig()->registration->passMinLength - 1); + $newPassword = str_repeat('a', Core::getConfig()->registration->passMinLength - 1); $oldPasswordHash = $user->getPasswordHash(); $this->assert->throws(function() use ($user, $newPassword) @@ -51,7 +51,7 @@ class EditUserPasswordJobTest extends AbstractTest $this->assert->areEqual($newPasswordHash, $user->getPasswordHash()); - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; $this->assert->doesNotThrow(function() use ($user, $newPassword) { Auth::login($user->getName(), $newPassword, false); diff --git a/tests/Tests/JobTests/GetLogJobTest.php b/tests/Tests/JobTests/GetLogJobTest.php index 0b2a9451..48d57af8 100644 --- a/tests/Tests/JobTests/GetLogJobTest.php +++ b/tests/Tests/JobTests/GetLogJobTest.php @@ -37,7 +37,7 @@ class GetLogJobTest extends AbstractTest private function run($args) { - getConfig()->browsing->logsPerPage = 2; + Core::getConfig()->browsing->logsPerPage = 2; $this->grantAccess('viewLog'); Logger::log('line1'); Logger::log('line2'); diff --git a/tests/Tests/JobTests/GetPostThumbJobTest.php b/tests/Tests/JobTests/GetPostThumbJobTest.php index f3c1f9a6..d78fe3b1 100644 --- a/tests/Tests/JobTests/GetPostThumbJobTest.php +++ b/tests/Tests/JobTests/GetPostThumbJobTest.php @@ -18,7 +18,7 @@ class GetPostThumbJobTest extends AbstractTest $this->assert->isNotNull($post->tryGetWorkingFullPath()); $this->assert->areEqual('image/jpeg', $output->mimeType); $this->assert->areNotEqual( - file_get_contents(getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'), + file_get_contents(Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'), $output->fileContent); } diff --git a/tests/Tests/JobTests/ListCommentsJobTest.php b/tests/Tests/JobTests/ListCommentsJobTest.php index 477d0ca1..78bc2951 100644 --- a/tests/Tests/JobTests/ListCommentsJobTest.php +++ b/tests/Tests/JobTests/ListCommentsJobTest.php @@ -44,7 +44,7 @@ class ListCommentJobTest extends AbstractTest $this->grantAccess('listComments'); $this->grantAccess('listPosts'); - getConfig()->comments->commentsPerPage = 2; + Core::getConfig()->comments->commentsPerPage = 2; $this->assert->areEqual(0, CommentModel::getCount()); diff --git a/tests/Tests/JobTests/ListLogsJobTest.php b/tests/Tests/JobTests/ListLogsJobTest.php index 5c174eb3..842cda7c 100644 --- a/tests/Tests/JobTests/ListLogsJobTest.php +++ b/tests/Tests/JobTests/ListLogsJobTest.php @@ -5,12 +5,12 @@ class ListLogsJobTest extends AbstractTest { $this->grantAccess('listLogs'); - getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test1.log'); + Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test1.log'); Logger::init(); Logger::log('nonsense'); - getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test2.log'); + Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test2.log'); Logger::init(); Logger::log('nonsense'); diff --git a/tests/Tests/JobTests/ListPostsJobTest.php b/tests/Tests/JobTests/ListPostsJobTest.php index b4474142..6b47c043 100644 --- a/tests/Tests/JobTests/ListPostsJobTest.php +++ b/tests/Tests/JobTests/ListPostsJobTest.php @@ -5,7 +5,7 @@ class ListPostsJobTest extends AbstractTest { $this->grantAccess('listPosts'); $posts = $this->postMocker->mockMultiple(3); - getConfig()->browsing->postsPerPage = 2; + Core::getConfig()->browsing->postsPerPage = 2; $ret = $this->assert->doesNotThrow(function() { diff --git a/tests/Tests/JobTests/ListRelatedTagsJobTest.php b/tests/Tests/JobTests/ListRelatedTagsJobTest.php index c0bc6e72..f8654dcd 100644 --- a/tests/Tests/JobTests/ListRelatedTagsJobTest.php +++ b/tests/Tests/JobTests/ListRelatedTagsJobTest.php @@ -7,7 +7,7 @@ class ListRelatedTagsJobTest extends AbstractTest $this->grantAccess('listPosts'); $tags = $this->tagMocker->mockMultiple(3); - getConfig()->browsing->tagsRelated = 1; + Core::getConfig()->browsing->tagsRelated = 1; $post = $this->postMocker->mockSingle(); $post->setTags($tags); diff --git a/tests/Tests/JobTests/ListTagsJobTest.php b/tests/Tests/JobTests/ListTagsJobTest.php index 355db9d8..dddd7c05 100644 --- a/tests/Tests/JobTests/ListTagsJobTest.php +++ b/tests/Tests/JobTests/ListTagsJobTest.php @@ -7,7 +7,7 @@ class ListTagsJobTest extends AbstractTest $this->grantAccess('listPosts'); $tags = $this->tagMocker->mockMultiple(3); - getConfig()->browsing->tagsPerPage = 2; + Core::getConfig()->browsing->tagsPerPage = 2; $post = $this->postMocker->mockSingle(); $post->setTags($tags); diff --git a/tests/Tests/JobTests/ListUsersJobTest.php b/tests/Tests/JobTests/ListUsersJobTest.php index 9b5f0bbc..40c8cf9a 100644 --- a/tests/Tests/JobTests/ListUsersJobTest.php +++ b/tests/Tests/JobTests/ListUsersJobTest.php @@ -6,7 +6,7 @@ class ListUsersJobTest extends AbstractTest $this->grantAccess('listUsers'); $users = $this->userMocker->mockMultiple(3); - getConfig()->browsing->usersPerPage = 2; + Core::getConfig()->browsing->usersPerPage = 2; $ret = $this->assert->doesNotThrow(function() { diff --git a/tests/Tests/JobTests/PasswordResetJobTest.php b/tests/Tests/JobTests/PasswordResetJobTest.php index 20d01faf..ed6434dd 100644 --- a/tests/Tests/JobTests/PasswordResetJobTest.php +++ b/tests/Tests/JobTests/PasswordResetJobTest.php @@ -3,7 +3,7 @@ class PasswordResetJobTest extends AbstractTest { public function testDontSendIfUnconfirmedMail() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); @@ -22,7 +22,7 @@ class PasswordResetJobTest extends AbstractTest public function testSending() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); @@ -54,7 +54,7 @@ class PasswordResetJobTest extends AbstractTest public function testObtainingNewPassword() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); @@ -94,7 +94,7 @@ class PasswordResetJobTest extends AbstractTest public function testUsingTokenTwice() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; Mailer::mockSending(); $user = $this->userMocker->mockSingle(); diff --git a/tests/Tests/JobTests/PreviewCommentJobTest.php b/tests/Tests/JobTests/PreviewCommentJobTest.php index 30d8e864..b38e600d 100644 --- a/tests/Tests/JobTests/PreviewCommentJobTest.php +++ b/tests/Tests/JobTests/PreviewCommentJobTest.php @@ -26,7 +26,7 @@ class PreviewCommentJobTest extends AbstractTest $this->prepare(); $this->assert->doesNotThrow(function() { - return $this->runApi(str_repeat('b', getConfig()->comments->minLength)); + return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength)); }); } @@ -35,7 +35,7 @@ class PreviewCommentJobTest extends AbstractTest $this->prepare(); $this->assert->doesNotThrow(function() { - return $this->runApi(str_repeat('b', getConfig()->comments->maxLength)); + return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength)); }); } @@ -44,7 +44,7 @@ class PreviewCommentJobTest extends AbstractTest $this->prepare(); $this->assert->throws(function() { - return $this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); + return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1)); }, 'Comment must have at least'); } @@ -53,7 +53,7 @@ class PreviewCommentJobTest extends AbstractTest $this->prepare(); $this->assert->throws(function() { - return $this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); + return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1)); }, 'Comment must have at most'); } @@ -106,7 +106,7 @@ class PreviewCommentJobTest extends AbstractTest protected function prepare() { - getConfig()->registration->needEmailForCommenting = false; + Core::getConfig()->registration->needEmailForCommenting = false; $this->grantAccess('addComment'); $this->login($this->userMocker->mockSingle()); } diff --git a/tests/Tests/MiscTests/AccessTest.php b/tests/Tests/MiscTests/AccessTest.php index 379317f1..e708353e 100644 --- a/tests/Tests/MiscTests/AccessTest.php +++ b/tests/Tests/MiscTests/AccessTest.php @@ -28,7 +28,7 @@ class AccessTest extends AbstractTest public function testAccessRanks2() { - getConfig()->privileges->listPosts = 'power-user'; + Core::getConfig()->privileges->listPosts = 'power-user'; Access::init(); $user = $this->userMocker->mockSingle(); @@ -50,7 +50,7 @@ class AccessTest extends AbstractTest public function testSubPrivilegesOnlySub() { - getConfig()->privileges->{'listPosts.own'} = 'power-user'; + Core::getConfig()->privileges->{'listPosts.own'} = 'power-user'; Access::init(); $user = $this->userMocker->mockSingle(); @@ -62,16 +62,16 @@ class AccessTest extends AbstractTest public function testSubPrivilegesSubAndGeneralNormalOrder() { - getConfig()->privileges->{'listPosts.own'} = 'power-user'; - getConfig()->privileges->{'listPosts'} = 'admin'; + Core::getConfig()->privileges->{'listPosts.own'} = 'power-user'; + Core::getConfig()->privileges->{'listPosts'} = 'admin'; Access::init(); $this->testSubPrivilegesSubAndGeneral(); } public function testSubPrivilegesSubAndGeneralReverseOrder() { - getConfig()->privileges->{'listPosts'} = 'admin'; - getConfig()->privileges->{'listPosts.own'} = 'power-user'; + Core::getConfig()->privileges->{'listPosts'} = 'admin'; + Core::getConfig()->privileges->{'listPosts.own'} = 'power-user'; Access::init(); $this->testSubPrivilegesSubAndGeneral(); } @@ -92,18 +92,18 @@ class AccessTest extends AbstractTest public function testSubPrivilegesMultipleSubAndGeneralNormalOrder() { - getConfig()->privileges->{'listPosts.own'} = 'power-user'; - getConfig()->privileges->{'listPosts.all'} = 'admin'; - getConfig()->privileges->{'listPosts'} = 'nobody'; + Core::getConfig()->privileges->{'listPosts.own'} = 'power-user'; + Core::getConfig()->privileges->{'listPosts.all'} = 'admin'; + Core::getConfig()->privileges->{'listPosts'} = 'nobody'; Access::init(); $this->testSubPrivilegesMultipleSubAndGeneral(); } public function testSubPrivilegesMultipleSubAndGeneralReverseOrder() { - getConfig()->privileges->{'listPosts'} = 'nobody'; - getConfig()->privileges->{'listPosts.own'} = 'power-user'; - getConfig()->privileges->{'listPosts.all'} = 'admin'; + Core::getConfig()->privileges->{'listPosts'} = 'nobody'; + Core::getConfig()->privileges->{'listPosts.own'} = 'power-user'; + Core::getConfig()->privileges->{'listPosts.all'} = 'admin'; Access::init(); $this->testSubPrivilegesMultipleSubAndGeneral(); } diff --git a/tests/Tests/MiscTests/AuthTest.php b/tests/Tests/MiscTests/AuthTest.php index a78da3b4..9af1c95f 100644 --- a/tests/Tests/MiscTests/AuthTest.php +++ b/tests/Tests/MiscTests/AuthTest.php @@ -3,8 +3,8 @@ class AuthTest extends AbstractTest { public function testValidPassword() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); UserModel::save($user); @@ -19,8 +19,8 @@ class AuthTest extends AbstractTest public function testLoginViaEmail() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); $user->setConfirmedEmail('godzilla@whitestar.gov'); @@ -65,8 +65,8 @@ class AuthTest extends AbstractTest public function testBanned() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); $user->ban(); @@ -80,8 +80,8 @@ class AuthTest extends AbstractTest public function testStaffConfirmationEnabledFail() { - getConfig()->registration->staffActivation = true; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = true; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); $user->setStaffConfirmed(false); @@ -95,8 +95,8 @@ class AuthTest extends AbstractTest public function testStaffConfirmationEnabledPass() { - getConfig()->registration->staffActivation = true; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = true; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); $user->setStaffConfirmed(true); @@ -112,8 +112,8 @@ class AuthTest extends AbstractTest public function testStaffConfirmationDisabledPass() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = false; $user = $this->prepareValidUser(); $user->setStaffConfirmed(false); @@ -129,8 +129,8 @@ class AuthTest extends AbstractTest public function testMailConfirmationEnabledFail1() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = true; $user = $this->prepareValidUser(); $user->setStaffConfirmed(false); @@ -144,8 +144,8 @@ class AuthTest extends AbstractTest public function testMailConfirmationEnabledFail2() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = true; $user = $this->prepareValidUser(); $user->setStaffConfirmed(false); @@ -160,8 +160,8 @@ class AuthTest extends AbstractTest public function testMailConfirmationEnabledPass() { - getConfig()->registration->staffActivation = false; - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->staffActivation = false; + Core::getConfig()->registration->needEmailForRegistering = true; $user = $this->prepareValidUser(); $user->setStaffConfirmed(false); diff --git a/tests/Tests/MiscTests/LoggerTest.php b/tests/Tests/MiscTests/LoggerTest.php index d2a8f7c9..9b9e9be0 100644 --- a/tests/Tests/MiscTests/LoggerTest.php +++ b/tests/Tests/MiscTests/LoggerTest.php @@ -26,10 +26,10 @@ class LoggerTest extends AbstractTest public function testPathChanging() { - $logPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log'); - $realLogPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log'); + $logPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log'); + $realLogPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log'); - getConfig()->main->logsPath = $logPath; + Core::getConfig()->main->logsPath = $logPath; $this->assert->doesNotThrow(function() { Logger::init(); diff --git a/tests/Tests/ModelTests/PostModelTest.php b/tests/Tests/ModelTests/PostModelTest.php index 08cef62b..c34883f5 100644 --- a/tests/Tests/ModelTests/PostModelTest.php +++ b/tests/Tests/ModelTests/PostModelTest.php @@ -74,7 +74,7 @@ class PostModelTest extends AbstractTest public function testAutoFeaturingOutdated() { $post = $this->postMocker->mockSingle(); - $minTimestamp = getConfig()->misc->featuredPostMaxDays * 24 * 3600; + $minTimestamp = Core::getConfig()->misc->featuredPostMaxDays * 24 * 3600; $this->assert->isTrue(PostModel::featureRandomPostIfNecessary()); PropertyModel::set(PropertyModel::FeaturedPostUnixTime, time() - $minTimestamp - 1); diff --git a/tests/Tests/ModelTests/UserModelTest.php b/tests/Tests/ModelTests/UserModelTest.php index 4620cb4d..afde1119 100644 --- a/tests/Tests/ModelTests/UserModelTest.php +++ b/tests/Tests/ModelTests/UserModelTest.php @@ -3,7 +3,7 @@ class UserModelTest extends AbstractTest { public function testSavingTwoUsersSameNameNoActivation() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); $this->assert->throws(function() use ($user2) { @@ -13,7 +13,7 @@ class UserModelTest extends AbstractTest public function testSavingTwoUsersSameNameEmailActivation() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); $this->assert->throws(function() use ($user2) { @@ -23,7 +23,7 @@ class UserModelTest extends AbstractTest public function testSavingTwoUsersSameNameStaffActivation() { - getConfig()->registration->staffActivation = true; + Core::getConfig()->registration->staffActivation = true; list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); $this->assert->throws(function() use ($user2) { @@ -33,7 +33,7 @@ class UserModelTest extends AbstractTest public function testSavingTwoUsersSameEmailNoActivation() { - getConfig()->registration->needEmailForRegistering = false; + Core::getConfig()->registration->needEmailForRegistering = false; list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); $this->assert->throws(function() use ($user2) { @@ -43,7 +43,7 @@ class UserModelTest extends AbstractTest public function testSavingTwoUsersSameEmailEmailActivation() { - getConfig()->registration->needEmailForRegistering = true; + Core::getConfig()->registration->needEmailForRegistering = true; list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); $this->assert->throws(function() use ($user2) { @@ -53,7 +53,7 @@ class UserModelTest extends AbstractTest public function testSavingTwoUsersSameEmailStaffActivation() { - getConfig()->registration->staffActivation = true; + Core::getConfig()->registration->staffActivation = true; list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); $this->assert->throws(function() use ($user2) {