From 30c264211ebd826e411a6987c3e87ba8f0c8651e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Sat, 10 Oct 2015 00:01:39 +0200 Subject: [PATCH] MDL-49329 admin: Fix reported coding style warnings --- admin/index.php | 11 +-- admin/renderer.php | 16 ++-- .../tests/fixtures/testable_installer.php | 2 + lib/classes/plugin_manager.php | 4 +- lib/classes/update/code_manager.php | 2 +- lib/classes/update/validator.php | 76 +++++++++++-------- .../fixtures/testable_plugin_manager.php | 4 + .../fixtures/testable_update_checker.php | 10 ++- .../fixtures/testable_update_code_manager.php | 6 ++ .../lang/en/repository_mahara.php | 1 + .../version.php | 1 - .../installed/greenbar/index.php | 1 - .../greenbar/lang/en/local_greenbar.php | 1 - .../installed/greenbar/version.php | 1 - .../update_validator/multidir/one/version.php | 1 - .../nocomponent/baz/lang/en/auth_baz.php | 1 - .../nocomponent/baz/version.php | 3 +- .../update_validator/nolang/bah/index.php | 1 + .../nolang/bah/lang/en/bah.php | 1 + .../nolang/bah/lang/en/bleh.php | 1 - .../update_validator/nolang/bah/lib.php | 3 +- .../update_validator/nolang/bah/version.php | 1 - .../update_validator/nolang/bah/view.php | 1 - .../noversion/lang/en/noversion.php | 1 - .../noversion/lang/en/theme_noversion.php | 1 - .../update_validator/nowrapdir/index.php | 3 +- .../nowrapdir/lang/en/foo.php | 1 - .../update_validator/nowrapdir/version.php | 1 - .../plugindir/foobar/index.php | 1 - .../plugindir/foobar/lang/en/local_foobar.php | 1 - .../plugindir/foobar/version.php | 3 +- .../plugindir/legacymod/lang/en/legacymod.php | 1 - .../plugindir/legacymod/version.php | 1 - .../wronglang/bah/lang/en/bah.php | 1 - .../wronglang/bah/version.php | 1 - lib/tests/plugin_manager_test.php | 3 +- lib/tests/update_api_test.php | 2 +- lib/tests/update_validator_test.php | 23 ++++-- 38 files changed, 102 insertions(+), 91 deletions(-) diff --git a/admin/index.php b/admin/index.php index 3972513871b..b8de2e6237d 100644 --- a/admin/index.php +++ b/admin/index.php @@ -213,7 +213,6 @@ if (!core_tables_exist()) { $PAGE->set_heading($strinstallation); $PAGE->set_cacheable(false); - /** @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); echo $output->install_licence_page(); die(); @@ -228,7 +227,6 @@ if (!core_tables_exist()) { $PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release); $PAGE->set_cacheable(false); - /** @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release); die(); @@ -320,7 +318,6 @@ if (!$cache and $version > $CFG->version) { // upgrade // We then purge the regular caches. purge_all_caches(); - /** @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); if (upgrade_stale_php_files_present()) { @@ -526,10 +523,7 @@ if (!$cache and moodle_needs_upgrading()) { if (!$PAGE->headerprinted) { // means core upgrade or installation was not already done - /** @var core_plugin_manager $pluginman */ $pluginman = core_plugin_manager::instance(); - - /** @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); if (!$confirmplugins) { @@ -561,7 +555,8 @@ if (!$cache and moodle_needs_upgrading()) { } redirect($PAGE->url); } else { - $continue = new moodle_url($PAGE->url, array('abortinstallx' => $abortinstallx, 'confirmabortinstall' => 1)); + $continue = new moodle_url($PAGE->url, array('abortinstallx' => $abortinstallx, + 'confirmabortinstall' => 1)); echo $output->upgrade_confirm_abort_install_page($abortables, $continue); die(); } @@ -671,7 +666,6 @@ if (!$cache and moodle_needs_upgrading()) { // Make sure plugin dependencies are always checked. $failed = array(); if (!$pluginman->all_plugins_ok($version, $failed)) { - /** @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url); die(); @@ -852,7 +846,6 @@ $cachewarnings = cache_helper::warnings(); admin_externalpage_setup('adminnotifications'); -/* @var core_admin_renderer $output */ $output = $PAGE->get_renderer('core', 'admin'); echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems, diff --git a/admin/renderer.php b/admin/renderer.php index 14f116d3d26..12d9dc3119b 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -1068,8 +1068,8 @@ class core_admin_renderer extends plugin_renderer_base { $out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 1)), get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge')); - $out .= $this->output->container_end(); // .actions - $out .= $this->output->container_end(); // #plugins-check-info + $out .= $this->output->container_end(); // End of .actions container. + $out .= $this->output->container_end(); // End of #plugins-check-info container. if ($sumdisplayed > 0 or $options['full']) { $out .= html_writer::table($table); @@ -1082,7 +1082,7 @@ class core_admin_renderer extends plugin_renderer_base { * Display the continue / cancel widgets for the plugins management pages. * * @param null|moodle_url $continue URL for the continue button, should it be displayed - * @param moodle_url $cancel URL for the cancel link, defaults to the current page + * @param null|moodle_url $cancel URL for the cancel link, defaults to the current page * @return string HTML */ public function plugins_management_confirm_buttons(moodle_url $continue=null, moodle_url $cancel=null) { @@ -1159,7 +1159,7 @@ class core_admin_renderer extends plugin_renderer_base { $out .= $this->output->container_start('plugins-check-dependencies-actions'); $out .= ' '.html_writer::link(new moodle_url('/admin/tool/installaddon/'), get_string('dependencyuploadmissing', 'core_plugin')); - $out .= $this->output->container_end(); // .plugins-check-dependencies-actions + $out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container. } if ($available) { @@ -1179,12 +1179,12 @@ class core_admin_renderer extends plugin_renderer_base { $out .= html_writer::div(html_writer::link(new moodle_url('/admin/tool/installaddon/'), get_string('dependencyuploadmissing', 'core_plugin')), 'dependencyuploadmissing'); - $out .= $this->output->container_end(); // .plugins-check-dependencies-actions + $out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container. $out .= $this->available_missing_dependencies_list($pluginman, $available); } - $out .= $this->output->container_end(); // .plugins-check-dependencies + $out .= $this->output->container_end(); // End of .plugins-check-dependencies container. return $out; } @@ -1268,7 +1268,7 @@ class core_admin_renderer extends plugin_renderer_base { } } - $info .= $this->output->container_end(); // .actions + $info .= $this->output->container_end(); // End of .actions container. $table->data[] = array( html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component'), @@ -1487,7 +1487,7 @@ class core_admin_renderer extends plugin_renderer_base { html_writer::div($infoext, 'info info-ext'). html_writer::div($infoupdatable, 'info info-updatable'); - $out .= html_writer::end_div(); // #plugins-overview-panel + $out .= html_writer::end_div(); // End of #plugins-overview-panel block. return $out; } diff --git a/admin/tool/installaddon/tests/fixtures/testable_installer.php b/admin/tool/installaddon/tests/fixtures/testable_installer.php index 807382017be..c8ebd826bfb 100644 --- a/admin/tool/installaddon/tests/fixtures/testable_installer.php +++ b/admin/tool/installaddon/tests/fixtures/testable_installer.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Provides {@link testable_tool_installaddon_installer} class. + * * @package tool_installaddon * @subpackage fixtures * @category test diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 49fdcf5113a..6b1f3fcdf0f 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -939,7 +939,7 @@ class core_plugin_manager { * * @param string $component * @param int $version version number - * $param string $reason returned code of the reason why it is not + * @param string $reason returned code of the reason why it is not * @return boolean */ public function is_remote_plugin_installable($component, $version, &$reason=null) { @@ -1095,7 +1095,7 @@ class core_plugin_manager { * @param string $zipfilepath full path to the saved ZIP file * @param string $targetdir full path to the directory to extract the ZIP file to * @param string $rootdir explicitly rename the root directory of the ZIP into this non-empty value - * @param array list of extracted files as returned by {@link zip_packer::extract_to_pathname()} + * @return array list of extracted files as returned by {@link zip_packer::extract_to_pathname()} */ public function unzip_plugin_file($zipfilepath, $targetdir, $rootdir = '') { return $this->get_code_manager()->unzip_plugin_file($zipfilepath, $targetdir, $rootdir); diff --git a/lib/classes/update/code_manager.php b/lib/classes/update/code_manager.php index d20a14f5682..e18715fe862 100644 --- a/lib/classes/update/code_manager.php +++ b/lib/classes/update/code_manager.php @@ -155,7 +155,7 @@ class code_manager { * @param string $zipfilepath full path to the saved ZIP file * @param string $targetdir full path to the directory to extract the ZIP file to * @param string $rootdir explicitly rename the root directory of the ZIP into this non-empty value - * @param array list of extracted files as returned by {@link zip_packer::extract_to_pathname()} + * @return array list of extracted files as returned by {@link zip_packer::extract_to_pathname()} */ public function unzip_plugin_file($zipfilepath, $targetdir, $rootdir = '') { diff --git a/lib/classes/update/validator.php b/lib/classes/update/validator.php index e4e2a94fee3..7d0f997a678 100644 --- a/lib/classes/update/validator.php +++ b/lib/classes/update/validator.php @@ -36,9 +36,9 @@ use coding_exception; defined('MOODLE_INTERNAL') || die(); if (!defined('T_ML_COMMENT')) { - define('T_ML_COMMENT', T_COMMENT); + define('T_ML_COMMENT', T_COMMENT); } else { - define('T_DOC_COMMENT', T_ML_COMMENT); + define('T_DOC_COMMENT', T_ML_COMMENT); } /** @@ -263,6 +263,8 @@ class validator { // End of external API. /** + * No public constructor, use {@link self::instance()} instead. + * * @param string $zipcontentpath full path to the extracted ZIP contents * @param array $zipcontentfiles (string)filerelpath => (bool|string)true or error */ @@ -274,12 +276,14 @@ class validator { // Validation methods. /** - * @return bool false if files in the ZIP do not have required layout + * Returns false if files in the ZIP do not have required layout. + * + * @return bool */ protected function validate_files_layout() { if (!is_array($this->extractfiles) or count($this->extractfiles) < 4) { - // We need the English language pack with the name of the plugin at least + // We need the English language pack with the name of the plugin at least. $this->add_message(self::ERROR, 'filesnumber'); return false; } @@ -319,7 +323,9 @@ class validator { } /** - * @return bool false if the version.php file does not declare required information + * Returns false if the version.php file does not declare required information. + * + * @return bool */ protected function validate_version_php() { @@ -406,7 +412,9 @@ class validator { } /** - * @return bool false if the English language pack is not provided correctly + * Returns false if the English language pack is not provided correctly. + * + * @return bool */ protected function validate_language_pack() { @@ -456,7 +464,9 @@ class validator { } /** - * @return bool false of the given add-on can't be installed into its location + * Returns false of the given add-on can't be installed into its location. + * + * @return bool */ public function validate_target_location() { @@ -510,7 +520,7 @@ class validator { /** * Get as much information from existing version.php as possible * - * @param string full path to the version.php file + * @param string $fullpath full path to the version.php file * @return array of found meta-info declarations */ protected function parse_version_php($fullpath) { @@ -576,30 +586,30 @@ class validator { list($id, $text) = $token; } switch ($id) { - case T_WHITESPACE: - case T_COMMENT: - case T_ML_COMMENT: - case T_DOC_COMMENT: - // Ignore whitespaces, inline comments, multiline comments and docblocks. - break; - case T_OPEN_TAG: - // Start processing. - $doprocess = true; - break; - case T_CLOSE_TAG: - // Stop processing. - $doprocess = false; - break; - default: - // Anything else is within PHP tags, return it as is. - if ($doprocess) { - $output .= $text; - if ($text === 'function') { - // Explicitly keep the whitespace that would be ignored. - $output .= ' '; + case T_WHITESPACE: + case T_COMMENT: + case T_ML_COMMENT: + case T_DOC_COMMENT: + // Ignore whitespaces, inline comments, multiline comments and docblocks. + break; + case T_OPEN_TAG: + // Start processing. + $doprocess = true; + break; + case T_CLOSE_TAG: + // Stop processing. + $doprocess = false; + break; + default: + // Anything else is within PHP tags, return it as is. + if ($doprocess) { + $output .= $text; + if ($text === 'function') { + // Explicitly keep the whitespace that would be ignored. + $output .= ' '; + } } - } - break; + break; } } @@ -607,7 +617,7 @@ class validator { } /** - * Returns the full path to the root directory of the given plugin type + * Returns the full path to the root directory of the given plugin type. * * @param string $plugintype * @return string|null @@ -617,6 +627,8 @@ class validator { } /** + * Returns plugin manager to use. + * * @return core_plugin_manager */ protected function get_plugin_manager() { diff --git a/lib/tests/fixtures/testable_plugin_manager.php b/lib/tests/fixtures/testable_plugin_manager.php index 8e77d35bed7..4a298f9b2ff 100644 --- a/lib/tests/fixtures/testable_plugin_manager.php +++ b/lib/tests/fixtures/testable_plugin_manager.php @@ -43,6 +43,10 @@ class testable_core_plugin_manager extends core_plugin_manager { * * Do not forget to call our reset_caches() after using this method to force a new * singleton instance. + * + * @param string $type plugin type + * @param string $name plugin name + * @param \core\plugininfo\base $plugininfo plugin info class */ public function inject_testable_plugininfo($type, $name, \core\plugininfo\base $plugininfo) { diff --git a/lib/tests/fixtures/testable_update_checker.php b/lib/tests/fixtures/testable_update_checker.php index 4a29d34f15c..a34e8eaf0d0 100644 --- a/lib/tests/fixtures/testable_update_checker.php +++ b/lib/tests/fixtures/testable_update_checker.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace core\update; - /** * Provides \core\update\testable_checker class. * @@ -25,11 +23,15 @@ namespace core\update; * @copyright 2012, 2015 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +namespace core\update; defined('MOODLE_INTERNAL') || die(); /** * Modified version of {@link \core\update\checker} suitable for testing. + * + * @copyright 2012, 2015 David Mudrak + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class testable_checker extends checker { @@ -166,8 +168,12 @@ class testable_checker extends checker { } } + /** * Exception used to detect {@link checker::cron_execute()} calls. + * + * @copyright 2012, 2015 David Mudrak + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class testable_checker_cron_executed extends \Exception { } diff --git a/lib/tests/fixtures/testable_update_code_manager.php b/lib/tests/fixtures/testable_update_code_manager.php index 60de0e085f3..c6c62d75ab6 100644 --- a/lib/tests/fixtures/testable_update_code_manager.php +++ b/lib/tests/fixtures/testable_update_code_manager.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Provides {@link testable_code_manager} class. + * * @package core_plugin * @category test * @copyright 2015 David Mudrak @@ -44,6 +46,10 @@ class testable_code_manager extends code_manager { * * It simply creates a new file in the given location, the contents of * which is the URL itself. + * + * @param string $url URL to the file + * @param string $tofile full path to where to store the downloaded file + * @return bool */ protected function download_file_content($url, $tofile) { $this->downloadscounter++; diff --git a/lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/lang/en/repository_mahara.php b/lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/lang/en/repository_mahara.php index b3d9bbc7f37..4f3bc0fd198 100644 --- a/lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/lang/en/repository_mahara.php +++ b/lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/lang/en/repository_mahara.php @@ -1 +1,2 @@ component = 'repository_mahara'; $plugin->version = 2014010100; diff --git a/lib/tests/fixtures/update_validator/installed/greenbar/index.php b/lib/tests/fixtures/update_validator/installed/greenbar/index.php index c65b6f7652d..172deb7e30b 100644 --- a/lib/tests/fixtures/update_validator/installed/greenbar/index.php +++ b/lib/tests/fixtures/update_validator/installed/greenbar/index.php @@ -1,3 +1,2 @@ version = 2013031900; $plugin->component = 'local_greenbar'; diff --git a/lib/tests/fixtures/update_validator/multidir/one/version.php b/lib/tests/fixtures/update_validator/multidir/one/version.php index 84af5f26a90..701d0349a96 100644 --- a/lib/tests/fixtures/update_validator/multidir/one/version.php +++ b/lib/tests/fixtures/update_validator/multidir/one/version.php @@ -1,3 +1,2 @@ component = 'local_one'; diff --git a/lib/tests/fixtures/update_validator/nocomponent/baz/lang/en/auth_baz.php b/lib/tests/fixtures/update_validator/nocomponent/baz/lang/en/auth_baz.php index 4422fa6f2cf..13cee454778 100644 --- a/lib/tests/fixtures/update_validator/nocomponent/baz/lang/en/auth_baz.php +++ b/lib/tests/fixtures/update_validator/nocomponent/baz/lang/en/auth_baz.php @@ -1,3 +1,2 @@ component missing in its version.php'; diff --git a/lib/tests/fixtures/update_validator/nocomponent/baz/version.php b/lib/tests/fixtures/update_validator/nocomponent/baz/version.php index f87367e5954..1c6679dc2da 100644 --- a/lib/tests/fixtures/update_validator/nocomponent/baz/version.php +++ b/lib/tests/fixtures/update_validator/nocomponent/baz/version.php @@ -1,5 +1,4 @@ version = 2015080600; $plugin->release = 'B.A.Z. Auth fake plugin'; -//$plugin->component is missing here so the validation must fail. +// $plugin->component is missing here so the validation must fail. diff --git a/lib/tests/fixtures/update_validator/nolang/bah/index.php b/lib/tests/fixtures/update_validator/nolang/bah/index.php index b3d9bbc7f37..4f3bc0fd198 100644 --- a/lib/tests/fixtures/update_validator/nolang/bah/index.php +++ b/lib/tests/fixtures/update_validator/nolang/bah/index.php @@ -1 +1,2 @@ version = 2014122455; $plugin->component = 'mod_bah'; diff --git a/lib/tests/fixtures/update_validator/nolang/bah/view.php b/lib/tests/fixtures/update_validator/nolang/bah/view.php index 654f0709e84..6a3a63f3e7e 100644 --- a/lib/tests/fixtures/update_validator/nolang/bah/view.php +++ b/lib/tests/fixtures/update_validator/nolang/bah/view.php @@ -1,3 +1,2 @@ version = 2013031900; $plugin->component = 'local_foobar'; $plugin->requires = 2013031200; $plugin->maturity = MATURITY_ALPHA; -//$plugin->release = 'And this is commented'; +// $plugin->release = 'And this is commented'; diff --git a/lib/tests/fixtures/update_validator/plugindir/legacymod/lang/en/legacymod.php b/lib/tests/fixtures/update_validator/plugindir/legacymod/lang/en/legacymod.php index 01e066e67ad..a9bccab4589 100644 --- a/lib/tests/fixtures/update_validator/plugindir/legacymod/lang/en/legacymod.php +++ b/lib/tests/fixtures/update_validator/plugindir/legacymod/lang/en/legacymod.php @@ -1,3 +1,2 @@ version = 2013031900; diff --git a/lib/tests/fixtures/update_validator/wronglang/bah/lang/en/bah.php b/lib/tests/fixtures/update_validator/wronglang/bah/lang/en/bah.php index 70668e823db..e96909565b2 100644 --- a/lib/tests/fixtures/update_validator/wronglang/bah/lang/en/bah.php +++ b/lib/tests/fixtures/update_validator/wronglang/bah/lang/en/bah.php @@ -1,3 +1,2 @@ version = 2014122455; $plugin->component = 'block_bah'; diff --git a/lib/tests/plugin_manager_test.php b/lib/tests/plugin_manager_test.php index 917bd240caf..4aa0a0732f0 100644 --- a/lib/tests/plugin_manager_test.php +++ b/lib/tests/plugin_manager_test.php @@ -369,11 +369,12 @@ class core_plugin_manager_testcase extends advanced_testcase { } /** + * The combination of ANY_VERSION + $exactmatch is illegal. + * * @expectedException moodle_exception */ public function test_get_remote_plugin_info_exception() { $pluginman = testable_core_plugin_manager::instance(); - // The combination of ANY_VERSION + $exactmatch is illegal. $pluginman->get_remote_plugin_info('any_thing', ANY_VERSION, true); } diff --git a/lib/tests/update_api_test.php b/lib/tests/update_api_test.php index 32cfc7622a4..9454ae6844d 100644 --- a/lib/tests/update_api_test.php +++ b/lib/tests/update_api_test.php @@ -126,7 +126,7 @@ class core_update_api_testcase extends advanced_testcase { $this->assertInstanceOf('\core\update\remote_info', $client->validate_pluginfo_format($data)); $this->assertEquals(json_encode($data), json_encode($client->validate_pluginfo_format($data))); - // All properties must be present; + // All properties must be present. unset($data->version); $this->assertFalse($client->validate_pluginfo_format($data)); diff --git a/lib/tests/update_validator_test.php b/lib/tests/update_validator_test.php index f8342a9be25..99e7f03f560 100644 --- a/lib/tests/update_validator_test.php +++ b/lib/tests/update_validator_test.php @@ -49,7 +49,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filenotexists', array('file' => 'null/'))); - // Missing expected file + // Missing expected file. $validator = testable_core_update_validator::instance($fixtures.'/plugindir', array( 'foobar/' => true, 'foobar/version.php' => true, @@ -62,7 +62,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filenotexists', array('file' => 'foobar/NOTEXISTS.txt'))); - // Errors during ZIP extraction + // Errors during ZIP extraction. $validator = testable_core_update_validator::instance($fixtures.'/multidir', array( 'one/' => true, 'one/version.php' => 'Can not write target file', @@ -72,14 +72,14 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filestatus', array('file' => 'one/version.php', 'status' => 'Can not write target file'))); - // Insufficient number of extracted files + // Insufficient number of extracted files. $validator = testable_core_update_validator::instance($fixtures.'/emptydir', array( 'emptydir/' => true, 'emptydir/README.txt' => true)); $this->assertFalse($validator->execute()); $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filesnumber')); - // No wrapping directory + // No wrapping directory. $validator = testable_core_update_validator::instance($fixtures.'/nowrapdir', array( 'version.php' => true, 'index.php' => true, @@ -89,7 +89,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertFalse($validator->execute()); $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'onedir')); - // Multiple directories + // Multiple directories. $validator = testable_core_update_validator::instance($fixtures.'/multidir', array( 'one/' => true, 'one/version.php' => true, @@ -98,7 +98,7 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertFalse($validator->execute()); $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'onedir')); - // Invalid root directory name + // Invalid root directory name. $validator = testable_core_update_validator::instance($fixtures.'/github', array( 'moodle-repository_mahara-master/' => true, 'moodle-repository_mahara-master/lang/' => true, @@ -353,8 +353,15 @@ class core_update_validator_testcase extends advanced_testcase { $this->assertSame('', $validator->message_code_info('some_really_crazy_message_code_that_is_not_localised', 'something')); } - // Helper methods. - + /** + * Helper method for checking if the given message has been raised by the validator. + * + * @param array $messages list of returned messages + * @param string $level expected message severity level + * @param string $msgcode expected message code + * @param string|array $addinfo expected additional info + * @return bool + */ protected function has_message(array $messages, $level, $msgcode, $addinfo = null) { foreach ($messages as $message) { if ($message->level === $level and $message->msgcode === $msgcode and $message->addinfo === $addinfo) {