Skip to content
Snippets Groups Projects
Commit 3af0559e authored by Matti Harjula's avatar Matti Harjula
Browse files

Fix the previous unit tests for MaximaPool commit and add more sane...

Fix the previous unit tests for MaximaPool commit and add more sane assumptions to the unit test builder.
parent db98398f
No related branches found
No related tags found
No related merge requests found
......@@ -185,6 +185,8 @@ if ($cs->get_valid('t')) {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'t\'));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -204,6 +206,8 @@ for ($is = 0; $is <= 5; $is++) {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . '));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -226,6 +230,8 @@ for ($is = 0; $is <= 5; $is++) {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . '));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -251,6 +257,8 @@ if ($allow !== '') {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -276,6 +284,8 @@ if ($allow !== '') {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -302,6 +312,8 @@ if ($forbid !== '') {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -327,6 +339,8 @@ if ($forbid !== '') {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -353,6 +367,8 @@ if (count($keys) > 0) {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -378,6 +394,8 @@ if (count($keys) > 0) {
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -417,6 +435,8 @@ if (($allow !== '' && $forbid !== '') ||
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......@@ -453,6 +473,8 @@ if (($allow !== '' && $forbid !== '') ||
$out .= $nl . $indent2 . '$this->assertEquals(\'' . $cs->get_casstring() . '\', $cs->get_casstring());';
} else {
$out .= $nl . $indent2 . '$this->assertFalse($cs->get_valid(\'s\', true, ' . $is . ', $security));';
// In all cases if it is invalid there must be some error messages.
$out .= $nl . $indent2 . '$this->assertTrue(count($cs->get_errors(true)) > 0);';
}
$out .= $nl . $indent .'}';
......
......@@ -54,8 +54,7 @@ function xmldb_qtype_stack_install() {
// If this is a PHP unit test site, automatically create maxima_opt_auto.
// Should probably consider doing this for real in the future.
if ($platform != 'win' && (PHPUNIT_TEST || defined('BEHAT_UTIL')) &&
QTYPE_STACK_TEST_CONFIG_PLATFORM !== 'server') {
if ($platform != 'win' && (PHPUNIT_TEST || defined('BEHAT_UTIL'))) {
// Set to the same defaults as in settings.php - however, that has not been done
// yet in the Moodle install code flow, so we have to duplicate here.
set_config('maximaversion', 'default', 'qtype_stack');
......@@ -75,9 +74,11 @@ function xmldb_qtype_stack_install() {
set_config('casdebugging', 1, 'qtype_stack');
set_config('mathsdisplay', 'mathjax', 'qtype_stack');
if (QTYPE_STACK_TEST_CONFIG_PLATFORM !== 'server') {
list($ok, $message) = stack_cas_configuration::create_auto_maxima_image();
if (!$ok) {
throw new coding_exception('maxima_opt_auto creation failed.', $message);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment