Code cleanup to meet code standards.

This commit is contained in:
Daniel Thee Roperto
2016-11-14 19:20:46 +11:00
parent 5961e82b85
commit 7f264a85da
5 changed files with 22 additions and 14 deletions

View File

@@ -71,16 +71,6 @@ class outagelib {
return;
}
// Check if warning bar should be hidden.
if (optional_param('auth_outage_hide_warning', false, PARAM_BOOL)) {
return;
}
// Used to test the try block in case of errors.
if (PHPUNIT_TEST && optional_param('auth_outage_break_code', false, PARAM_INT)) {
(new stdClass())->invalidfield;
}
// Check for a previewing outage, then for an active outage.
$previewid = optional_param('auth_outage_preview', null, PARAM_INT);
$time = time();
@@ -200,6 +190,16 @@ class outagelib {
return false;
}
// Check if warning bar should be hidden.
if (optional_param('auth_outage_hide_warning', false, PARAM_BOOL)) {
return false;
}
// Used to test the try block in case of errors.
if (PHPUNIT_TEST && optional_param('auth_outage_break_code', false, PARAM_INT)) {
(new stdClass())->invalidfield; // Triggers an exception.
}
// Nothing preventing the injection.
return true;
}

View File

@@ -54,6 +54,11 @@ header('Pragma: ');
header('Cache-Control: public, max-age='.$lifetime);
header('Accept-Ranges: none');
/**
* Callback used in bootstrap.
* @SupressWarnings(PHPMD)
*/
function auth_outage_bootstrap_callback() {
global $CFG;
@@ -72,8 +77,8 @@ function auth_outage_bootstrap_callback() {
}
readfile($file);
die();
};
exit(0);
}
require_once(__DIR__.'/../../config.php');

View File

@@ -44,7 +44,7 @@ abstract class auth_outage_cli_testcase extends auth_outage_base_testcase {
public function setUp() {
global $CFG;
// PHPUnit does not load config.php
// PHPUnit does not load config.php file.
$CFG->auth_outage_bootstrap_loaded = true;
// Enable auth plugins.

View File

@@ -1 +1,3 @@
/* csslint ignore:start */
@import url(../simple.css);
/* csslint ignore:end */

View File

@@ -38,6 +38,7 @@ require_once(__DIR__.'/../../base_testcase.php');
* @copyright 2016 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @SuppressWarnings(public) Allow as many methods as needed.
* @SuppressWarnings(methods) Allow as many methods as needed.
*/
class maintenance_static_page_test extends auth_outage_base_testcase {
public function test_templatefile() {
@@ -130,7 +131,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
$page->generate();
// Check for css file.
self::assertFileExists($page->get_io()->get_resources_folder().'/4ea71b83ab326a15d0d784b34fcda702b6a7427d.dGV4dC9wbGFpbg');
self::assertFileExists($page->get_io()->get_resources_folder().'/beb44281e23b9d872056bf0230cea34535e8cdea.dGV4dC9wbGFpbg');
// Check for file referenced in url(..) of css.
self::assertFileExists($page->get_io()->get_resources_folder().'/a02a8a442fa82d5205ffb24722d9df7f35161f56.dGV4dC9wbGFpbg');