MDL-38989 detect changed timeout in tests

The trouble is that PHPUnit should ideally test mostly low level libraries that should not change the timeouts.
This commit is contained in:
Petr Škoda
2013-04-10 09:48:57 +02:00
parent 95cd4369bb
commit 71fc50031d
3 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
phpunit_util::reset_all_database_sequences();
phpunit_util::$lastdbwrites = $DB->perf_get_writes(); // no db reset necessary
}
phpunit_util::reset_all_data();
phpunit_util::reset_all_data(null);
} else if ($this->resetAfterTest === false) {
if ($this->testdbtransaction) {
@@ -130,7 +130,7 @@ abstract class database_driver_testcase extends PHPUnit_Framework_TestCase {
self::$extradb->dispose();
self::$extradb = null;
}
phpunit_util::reset_all_data();
phpunit_util::reset_all_data(null);
parent::tearDownAfterClass();
}
+9 -5
View File
@@ -83,10 +83,13 @@ class phpunit_util extends testing_util {
* Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
*
* @static
* @param bool $logchanges log changes in global state and database in error log
* @param bool $detectchanges
* true - changes in global state and database are reported as errors
* false - no errors reported
* null - only critical problems are reported as errors
* @return void
*/
public static function reset_all_data($logchanges = false) {
public static function reset_all_data($detectchanges = false) {
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
// Stop any message redirection.
@@ -110,7 +113,7 @@ class phpunit_util extends testing_util {
$resetdb = self::reset_database();
$warnings = array();
if ($logchanges) {
if ($detectchanges === true) {
if ($resetdb) {
$warnings[] = 'Warning: unexpected database modification, resetting DB state';
}
@@ -147,8 +150,9 @@ class phpunit_util extends testing_util {
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
// TODO: MDL-38912 uncomment and fix all + somehow resolve timeouts in failed tests.
//$warnings[] = 'Warning: max_execution_time was changed.';
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to '.ini_get('max_execution_time');
}
set_time_limit(0);
}