MDL-51266 unittest: replaced low level phpunit_util calls

This commit is contained in:
rajesh Taneja
2015-09-23 15:44:57 +08:00
parent a91caeefc7
commit 551dce86ba
7 changed files with 87 additions and 85 deletions
+18 -13
View File
@@ -83,14 +83,14 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
// Deal with any debugging messages.
$debugerror = phpunit_util::display_debugging_messages();
phpunit_util::reset_debugging();
$this->resetDebugging();
if ($debugerror) {
trigger_error('Unenxpected debugging() call detected.', E_USER_NOTICE);
}
} catch (Exception $e) {
// cleanup after failed expectation
phpunit_util::reset_all_data();
self::resetAllData();
throw $e;
}
@@ -104,7 +104,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(null);
self::resetAllData(null);
} else if ($this->resetAfterTest === false) {
if ($this->testdbtransaction) {
@@ -118,16 +118,16 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
try {
$this->testdbtransaction->allow_commit();
} catch (dml_transaction_exception $e) {
phpunit_util::reset_all_data();
self::resetAllData();
throw new coding_exception('Invalid transaction state detected in test '.$this->getName());
}
}
phpunit_util::reset_all_data(true);
self::resetAllData(true);
}
// make sure test did not forget to close transaction
if ($DB->is_transaction_started()) {
phpunit_util::reset_all_data();
self::resetAllData();
if ($this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED
or $this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED
or $this->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) {
@@ -272,7 +272,7 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
* @param string $message
*/
public function assertDebuggingCalled($debugmessage = null, $debuglevel = null, $message = '') {
$debugging = phpunit_util::get_debugging_messages();
$debugging = $this->getDebuggingMessages();
$count = count($debugging);
if ($count == 0) {
@@ -297,7 +297,7 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
$this->assertSame($debuglevel, $debug->level, $message);
}
phpunit_util::reset_debugging();
$this->resetDebugging();
}
/**
@@ -305,7 +305,7 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
* @param string $message
*/
public function assertDebuggingNotCalled($message = '') {
$debugging = phpunit_util::get_debugging_messages();
$debugging = $this->getDebuggingMessages();
$count = count($debugging);
if ($message === '') {
@@ -446,16 +446,21 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
* @return void
*/
public static function tearDownAfterClass() {
phpunit_util::reset_all_data();
self::resetAllData();
}
/**
* Reset all database tables, restore global state and clear caches and optionally purge dataroot dir.
* @static
*
* @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 resetAllData() {
phpunit_util::reset_all_data();
public static function resetAllData($detectchanges = false) {
phpunit_util::reset_all_data($detectchanges);
}
/**