From: daniel Date: Mon, 27 Aug 2012 12:38:25 +0000 (+0200) Subject: Clean up transactions after test. X-Git-Tag: 1.31.0-rc.0~22584^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=167bea7e7eddbe53ccf7f82a742a9f0624f61a72;p=lhc%2Fweb%2Fwiklou.git Clean up transactions after test. MediaWikiTestCase::teardown() will now rollback any transactions left open by a test case. This is intended to make sure tests do not provide "interesting" results casued by transaction state leaking from other tests. Change-Id: Ia225251efd5aafbaa6674e2732ab1ba7761bfadc --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index c873c5165d..49c2a70109 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -115,7 +115,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } protected function tearDown() { - // Cleaning up temoporary files + // Cleaning up temporary files foreach ( $this->tmpfiles as $fname ) { if ( is_file( $fname ) || ( is_link( $fname ) ) ) { unlink( $fname ); @@ -124,6 +124,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } + // clean up open transactions + if( $this->needsDB() && $this->db ) { + while( $this->db->trxLevel() > 0 ) { + $this->db->rollback(); + } + } + parent::tearDown(); }