forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thanks Eloy Lafuente, Tim Hunt and Sam Hemelryk for valuable feedback and ideas.
- Loading branch information
Showing
36 changed files
with
1,896 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ CVS | |
/.project | ||
/.buildpath | ||
/.cache | ||
/phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?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 related utilities. | ||
* | ||
* Exit codes: | ||
* 0 - success | ||
* 1 - general error | ||
* 130 - coding error | ||
* 131 - configuration problem | ||
* 133 - drop existing data before installing | ||
* | ||
* @package tool_phpunit | ||
* @copyright 2012 Petr Skoda {@link http://skodak.org} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
define('PHPUNIT_CLI_UTIL', true); | ||
|
||
require(__DIR__ . '/../../../../lib/phpunit/bootstrap.php'); | ||
require_once($CFG->libdir.'/phpunit/lib.php'); | ||
require_once($CFG->libdir.'/adminlib.php'); | ||
require_once($CFG->libdir.'/upgradelib.php'); | ||
require_once($CFG->libdir.'/clilib.php'); | ||
require_once($CFG->libdir.'/pluginlib.php'); | ||
require_once($CFG->libdir.'/installlib.php'); | ||
|
||
// now get cli options | ||
list($options, $unrecognized) = cli_get_params( | ||
array( | ||
'drop' => false, | ||
'install' => false, | ||
'buildconfig' => false, | ||
'help' => false, | ||
), | ||
array( | ||
'h' => 'help' | ||
) | ||
); | ||
|
||
if ($unrecognized) { | ||
$unrecognized = implode("\n ", $unrecognized); | ||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); | ||
} | ||
|
||
$drop = $options['drop']; | ||
$install = $options['install']; | ||
$buildconfig = $options['buildconfig']; | ||
|
||
if ($options['help'] or (!$drop and !$install and !$buildconfig)) { | ||
$help = "Various PHPUnit utility functions | ||
Options: | ||
--drop Drop database and dataroot | ||
--install Install database | ||
--buildconfig Build /phpunit.xml from /phpunit.xml.dist that includes suites for all plugins and core | ||
-h, --help Print out this help | ||
Example: | ||
\$/usr/bin/php lib/phpunit/tool.php | ||
"; | ||
echo $help; | ||
die; | ||
} | ||
|
||
if ($buildconfig) { | ||
phpunit_util::build_config_file(); | ||
exit(0); | ||
|
||
} else if ($drop) { | ||
phpunit_util::drop_site(); | ||
// 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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} | ||
*/ | ||
|
||
define('NO_OUTPUT_BUFFERING', true); | ||
|
||
require(dirname(__FILE__) . '/../../../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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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; | ||
|
||
$ADMIN->add('development', new admin_externalpage('toolphpunit', get_string('pluginname', 'tool_phpunit'), "$CFG->wwwroot/$CFG->admin/tool/phpunit/index.php")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = 2012030800; // The current plugin version (Date: YYYYMMDDXX) | ||
$plugin->requires = 2012030100; // Requires this Moodle version | ||
$plugin->component = 'tool_phpunit'; // Full name of the plugin (used for diagnostics) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.