Skip to content

Commit

Permalink
MDL-32323 improve self-diagnostic messages
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 10, 2012
1 parent 8b5413c commit 219d1a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/phpunit/bootstraplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
*/
function phpunit_bootstrap_error($errorcode, $text = '') {
switch ($errorcode) {
case 0:
// this is not an error, just print information and exit
break;
case 1:
$text = 'Error: '.$text;
break;
Expand Down
11 changes: 8 additions & 3 deletions lib/phpunit/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public static function drop_site() {
global $DB, $CFG;

if (!self::is_test_site()) {
cli_error('Can not drop non-test sites!!', 131);
phpunit_bootstrap_error(131, 'Can not drop non-test site!!');
}

// purge dataroot
Expand Down Expand Up @@ -609,11 +609,16 @@ public static function install_site() {
global $DB, $CFG;

if (!self::is_test_site()) {
cli_error('Can not install non-test sites!!', 131);
phpunit_bootstrap_error(131, 'Can not install on non-test site!!');
}

if ($DB->get_tables()) {
cli_error('Database tables already installed, drop the site first.', 133);
list($errorcode, $message) = phpunit_util::testing_ready_problem();
if ($errorcode) {
phpunit_bootstrap_error(133, 'Database tables already installed, drop the site first.');
} else {
phpunit_bootstrap_error(0, 'Test database is already initialised');
}
}

$options = array();
Expand Down

0 comments on commit 219d1a4

Please sign in to comment.