first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for tool_phpunit.
*
* @package tool_phpunit
* @copyright 2018 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_phpunit\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for tool_phpunit implementing null_provider.
*
* @copyright 2018 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* All in one init script - PHP version.
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
die; // No access from web!
}
// Force OPcache reset if used, we do not want any stale caches
// when preparing test environment.
if (function_exists('opcache_reset')) {
opcache_reset();
}
define('IGNORE_COMPONENT_CACHE', true);
require_once(__DIR__.'/../../../../lib/clilib.php');
require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
require_once(__DIR__.'/../../../../lib/testing/lib.php');
list($options, $unrecognized) = cli_get_params(
[
'help' => false,
'disable-composer' => false,
'composer-upgrade' => true,
'composer-self-update' => true,
],
[
'h' => 'help',
]
);
$help = "
Utilities to initialise the PHPUnit test site.
Usage:
php init.php [--no-composer-self-update] [--no-composer-upgrade]
[--help]
--no-composer-self-update
Prevent upgrade of the composer utility using its self-update command
--no-composer-upgrade
Prevent update development dependencies using composer
--disable-composer
A shortcut to disable composer self-update and dependency update
Note: Installation of composer and/or dependencies will still happen as required
-h, --help Print out this help
Example from Moodle root directory:
\$ php admin/tool/phpunit/cli/init.php
";
if (!empty($options['help'])) {
echo $help;
exit(0);
}
echo "Initialising Moodle PHPUnit test environment...\n";
if ($options['disable-composer']) {
// Disable self-update and upgrade easily.
// Note: Installation will still occur regardless of this setting.
$options['composer-self-update'] = false;
$options['composer-upgrade'] = false;
}
// Install and update composer and dependencies as required.
testing_update_composer_dependencies($options['composer-self-update'], $options['composer-upgrade']);
$output = null;
exec('php --version', $output, $code);
if ($code != 0) {
phpunit_bootstrap_error(1, 'Can not execute \'php\' binary.');
}
chdir(__DIR__);
$output = null;
exec("php util.php --diag", $output, $code);
if ($code == PHPUNIT_EXITCODE_INSTALL) {
passthru("php util.php --install", $code);
if ($code != 0) {
exit($code);
}
} else if ($code == PHPUNIT_EXITCODE_REINSTALL) {
passthru("php util.php --drop", $code);
passthru("php util.php --install", $code);
if ($code != 0) {
exit($code);
}
} else if ($code != 0) {
echo implode("\n", $output)."\n";
exit($code);
}
passthru("php util.php --buildconfig", $code);
echo "\n";
echo "PHPUnit test environment setup complete.\n";
exit(0);
+154
View File
@@ -0,0 +1,154 @@
<?php
// This file is part of Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* PHPUnit related utilities.
*
* Exit codes: {@see phpunit_bootstrap_error()}
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
die; // No access from web!
}
define('IGNORE_COMPONENT_CACHE', true);
require_once(__DIR__.'/../../../../lib/clilib.php');
require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
require_once(__DIR__.'/../../../../lib/testing/lib.php');
// Now get cli options.
list($options, $unrecognized) = cli_get_params(
[
'drop' => false,
'install' => false,
'buildconfig' => false,
'buildcomponentconfigs' => false,
'diag' => false,
'run' => false,
'help' => false,
],
[
'h' => 'help',
]
);
// Basic check to see if phpunit is installed.
if (!file_exists(__DIR__.'/../../../../vendor/phpunit/phpunit/composer.json') ||
!file_exists(__DIR__.'/../../../../vendor/bin/phpunit') ||
!file_exists(__DIR__.'/../../../../vendor/autoload.php')) {
phpunit_bootstrap_error(PHPUNIT_EXITCODE_PHPUNITMISSING);
}
if ($options['install'] || $options['drop']) {
define('CACHE_DISABLE_ALL', true);
}
if ($options['run']) {
unset($options);
unset($unrecognized);
foreach ($_SERVER['argv'] as $k => $v) {
if (strpos($v, '--run') === 0) {
unset($_SERVER['argv'][$k]);
$_SERVER['argc'] = $_SERVER['argc'] - 1;
}
}
$_SERVER['argv'] = array_values($_SERVER['argv']);
require(__DIR__ . '/../../../../vendor/bin/phpunit');
exit(0);
}
define('PHPUNIT_UTIL', true);
require(__DIR__.'/../../../../vendor/autoload.php');
require(__DIR__ . '/../../../../lib/phpunit/bootstrap.php');
// From now on this is a regular moodle CLI_SCRIPT.
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/upgradelib.php');
require_once($CFG->libdir.'/clilib.php');
require_once($CFG->libdir.'/installlib.php');
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
$diag = $options['diag'];
$drop = $options['drop'];
$install = $options['install'];
$buildconfig = $options['buildconfig'];
$buildcomponentconfigs = $options['buildcomponentconfigs'];
if ($options['help'] || (!$drop && !$install && !$buildconfig && !$buildcomponentconfigs && !$diag)) {
$help = "Various PHPUnit utility functions
Options:
--drop Drop database and dataroot
--install Install database
--diag Diagnose installation and return error code only
--run Execute PHPUnit tests (alternative for standard phpunit binary)
--buildconfig Build /phpunit.xml from /phpunit.xml.dist that runs all tests
--buildcomponentconfigs
Build distributed phpunit.xml files for each component
-h, --help Print out this help
Example:
\$ php ".testing_cli_argument_path('/admin/tool/phpunit/cli/util.php')." --install
";
echo $help;
exit(0);
}
if ($diag) {
list($errorcode, $message) = phpunit_util::testing_ready_problem();
if ($errorcode) {
phpunit_bootstrap_error($errorcode, $message);
}
exit(0);
} else if ($buildconfig) {
if (phpunit_util::build_config_file()) {
exit(0);
} else {
phpunit_bootstrap_error(
PHPUNIT_EXITCODE_CONFIGWARNING,
'Can not create main /phpunit.xml configuration file, verify dirroot permissions'
);
}
} else if ($buildcomponentconfigs) {
phpunit_util::build_component_config_files();
exit(0);
} else if ($drop) {
// Make sure tests do not run in parallel.
test_lock::acquire('phpunit');
phpunit_util::drop_site(true);
// Note: we must stop here because $CFG is messed up and we can not reinstall, sorry.
exit(0);
} else if ($install) {
phpunit_util::install_site();
exit(0);
}
+38
View File
@@ -0,0 +1,38 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* PHPUnit info
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__ . '/../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('toolphpunit');
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'tool_phpunit'));
echo $OUTPUT->box_start();
$info = file_get_contents("$CFG->libdir/phpunit/readme.md");
echo markdown_to_html($info);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
@@ -0,0 +1,26 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'tool_phpunit'
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'PHPUnit tests';
$string['privacy:metadata'] = 'The PHPUnit tests plugin does not store any personal data.';
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* PHPunit integration
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$ADMIN->add('development', new admin_externalpage('toolphpunit', get_string('pluginname', 'tool_phpunit'), "$CFG->wwwroot/$CFG->admin/tool/phpunit/index.php"));
}
+4
View File
@@ -0,0 +1,4 @@
This files describes API changes in the tool_phpunit code.
=== 3.9 ===
* webrunner was removed
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plugin version info
*
* @package tool_phpunit
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'tool_phpunit'; // Full name of the plugin (used for diagnostics)