mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-49329 admin: Fix reported coding style warnings
This commit is contained in:
parent
dbdd02c1fe
commit
30c264211e
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides {@link testable_tool_installaddon_installer} class.
|
||||
*
|
||||
* @package tool_installaddon
|
||||
* @subpackage fixtures
|
||||
* @category test
|
||||
|
@ -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);
|
||||
|
@ -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 = '') {
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
||||
|
10
lib/tests/fixtures/testable_update_checker.php
vendored
10
lib/tests/fixtures/testable_update_checker.php
vendored
@ -14,8 +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/>.
|
||||
|
||||
namespace core\update;
|
||||
|
||||
/**
|
||||
* Provides \core\update\testable_checker class.
|
||||
*
|
||||
@ -25,11 +23,15 @@ namespace core\update;
|
||||
* @copyright 2012, 2015 David Mudrak <david@moodle.com>
|
||||
* @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 <david@moodle.com>
|
||||
* @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 <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class testable_checker_cron_executed extends \Exception {
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides {@link testable_code_manager} class.
|
||||
*
|
||||
* @package core_plugin
|
||||
* @category test
|
||||
* @copyright 2015 David Mudrak <david@moodle.com>
|
||||
@ -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++;
|
||||
|
@ -1 +1,2 @@
|
||||
<?php
|
||||
// This file is empty.
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
|
||||
$plugin->component = 'repository_mahara';
|
||||
$plugin->version = 2014010100;
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
echo 'One, my little hobbit, never installs malicisous add-ons';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'Foo bar!';
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2013031900;
|
||||
$plugin->component = 'local_greenbar';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$plugin->component = 'local_one';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'This is a plugin with $plugin->component missing in its version.php';
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
$plugin->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.
|
||||
|
@ -1 +1,2 @@
|
||||
<?php
|
||||
// This file is empty.
|
||||
|
@ -1 +1,2 @@
|
||||
<?php
|
||||
// This file is empty.
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginnname'] = 'Root directory mismatch';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
|
||||
// This file is empty.
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2014122455;
|
||||
$plugin->component = 'mod_bah';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
echo 'Do not use hardcoded strings, provide the language pack';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginversion'] = 'Activity module with no version.php';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginversion'] = 'A theme with no version.php';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
// index.php
|
||||
// This file is empty.
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'Foo!';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php // $Id$
|
||||
|
||||
// I don't miss CVS, do you?
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
echo 'One, my little hobbit, never installs malicisous add-ons';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'Foo bar!';
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
$plugin->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';
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['modulename'] = 'Legacy activity module with $module in version.php';
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
|
||||
// Support for the $module has been dropped in Moodle 3.0.
|
||||
$module->version = 2013031900;
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
|
||||
$string['pluginname'] = 'This would be valid filename for module, not a block';
|
||||
|
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
|
||||
$plugin->version = 2014122455;
|
||||
$plugin->component = 'block_bah';
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user