mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
cleanup: fixup to match coding standards
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace auth_outage;
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
/**
|
||||
* Base testcase for auth outage tests.
|
||||
*
|
||||
@@ -30,20 +35,6 @@
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_outage;
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
/**
|
||||
* base_testcase class.
|
||||
*
|
||||
* @package auth_outage
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class base_testcase extends \advanced_testcase {
|
||||
/**
|
||||
* Checks PHPUnit version and calls the functions accordingly.
|
||||
@@ -72,7 +63,7 @@ abstract class base_testcase extends \advanced_testcase {
|
||||
protected function revoke_info_page_permissions() {
|
||||
global $DB;
|
||||
|
||||
$guestrole = $DB->get_record('role', array('shortname' => 'guest'));
|
||||
$guestrole = $DB->get_record('role', ['shortname' => 'guest']);
|
||||
role_change_permission($guestrole->id, \context_system::instance(), 'auth/outage:viewinfo', CAP_PREVENT);
|
||||
|
||||
$this->setGuestUser();
|
||||
|
||||
@@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* tests for lib.php
|
||||
*
|
||||
* @package auth_outage
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2017 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_outage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -199,26 +199,27 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
|
||||
* Data provider for test_update_inline_background_images
|
||||
* @return array
|
||||
*/
|
||||
public function test_update_inline_background_images_provider() {
|
||||
public static function update_inline_background_images_provider(): array {
|
||||
return [
|
||||
// Empty string.
|
||||
["", false],
|
||||
// URLs that should be retrieved.
|
||||
["color: #FF00FF; background: lightblue url(/pluginfile.php/1/theme_custom/banner/251298630/0001.png) no-repeat", true],
|
||||
["background: lightblue url(https://www.example.com/moodle/pluginfile.php/1/theme_custom/banner/251298630/0001.png) no-repeat", true],
|
||||
["background: lightblue
|
||||
url(https://www.example.com/moodle/pluginfile.php/1/theme_custom/banner/251298630/0001.png) no-repeat", true],
|
||||
["background:url('https://www.example.com/moodle/pluginfile.php/1/theme_custom/banner/251298630/0001.png')", true],
|
||||
["background-image : url( /pix/help.png);", true],
|
||||
["background-image: url ('/pix/help.png')", true],
|
||||
// URLs that should not be retrieved.
|
||||
["background-image:url(data:image/gif;base64,R0lGODlhYADIAP=)", false],
|
||||
["background-image:url('data:image/gif;base64,R0lGODlhYADIAP=')", false]
|
||||
["background-image:url('data:image/gif;base64,R0lGODlhYADIAP=')", false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests update_inline_background_images() method to update the background images.
|
||||
*
|
||||
* @dataProvider test_update_inline_background_images_provider
|
||||
* @dataProvider update_inline_background_images_provider
|
||||
* @param string $stylecontent Content of the style to test
|
||||
* @param bool $rewrite Flag if URL should be rewritten
|
||||
* @throws coding_exception
|
||||
@@ -372,14 +373,14 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
|
||||
/**
|
||||
* Return array of url data provider and true or false.
|
||||
*/
|
||||
public function is_url_dataprovider() {
|
||||
public static function is_url_dataprovider(): array {
|
||||
return [
|
||||
[true, 'http://catalyst.net.nz'],
|
||||
[true, 'https://www.catalyst-au.net/'],
|
||||
[false, '/homepage'],
|
||||
[false, 'file://homepage'],
|
||||
[true, '//catalyst-au.net/img/test.jpg'],
|
||||
[false, '://www.catalyst-au.net/img/test.jpg']
|
||||
[false, '://www.catalyst-au.net/img/test.jpg'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -560,7 +561,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
|
||||
* Data provider for test_get_urls_from_stylesheet
|
||||
* @return array
|
||||
*/
|
||||
public function test_get_urls_from_stylesheet_provider() {
|
||||
public static function get_urls_from_stylesheet_provider(): array {
|
||||
return [
|
||||
// Empty string.
|
||||
["", 0],
|
||||
@@ -582,7 +583,7 @@ class maintenance_static_page_test extends \auth_outage\base_testcase {
|
||||
/**
|
||||
* Tests get_urls_from_stylesheet() method to get all appropriate URLS from the file.
|
||||
*
|
||||
* @dataProvider test_get_urls_from_stylesheet_provider
|
||||
* @dataProvider get_urls_from_stylesheet_provider
|
||||
* @param string $filecontent Content of the file
|
||||
* @param int $count Expected quantity of found URLs
|
||||
* @throws coding_exception
|
||||
|
||||
@@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* outage_test test class.
|
||||
*
|
||||
* @package auth_outage
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_outage\local;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* outagelib_test test class.
|
||||
*
|
||||
* @package auth_outage
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace auth_outage\local;
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
@@ -361,7 +352,7 @@ EOT;
|
||||
* Test create maintenance php code without age
|
||||
*
|
||||
* @param string $configkey The key of the config.
|
||||
* @dataProvider test_createmaintenancephpcode_withoutage_provider
|
||||
* @dataProvider createmaintenancephpcode_withoutage_provider
|
||||
*/
|
||||
public function test_createmaintenancephpcode_withoutage($configkey) {
|
||||
global $CFG;
|
||||
@@ -414,7 +405,11 @@ EOT;
|
||||
self::assertSame($found, $expected);
|
||||
}
|
||||
|
||||
public function test_createmaintenancephpcode_withoutage_provider(): array {
|
||||
/**
|
||||
* Provides values to test_createmaintenancephpcode_withoutage
|
||||
* @return array
|
||||
*/
|
||||
public static function createmaintenancephpcode_withoutage_provider(): array {
|
||||
return [['allowedips'], ['allowedips_forced']];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user