From 167bea7e7eddbe53ccf7f82a742a9f0624f61a72 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 27 Aug 2012 14:38:25 +0200 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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(); } -- 2.20.1