From: Kunal Mehta Date: Wed, 1 Aug 2018 07:19:10 +0000 (-0700) Subject: Introduce MediaWikiTestCase::markTestSkippedIfDbType() X-Git-Tag: 1.34.0-rc.0~4592^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=04986dab93539b562c832bbd7dba03a55b6d049c;p=lhc%2Fweb%2Fwiklou.git Introduce MediaWikiTestCase::markTestSkippedIfDbType() Helper to skip tests if they're being run with a specific DBMS where the test currently fails. The main use case for this is to temporarily disable failing postgres and sqlite tests so we can make those test runs voting (so we don't regress any further), and re-enable the tests once they've been fixed. Change-Id: I1fd7ca6b2d21fed59ed387376d03489c7cbccdfe --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index db75bc0b58..382bf500fe 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -2170,6 +2170,18 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { return $loaded; } + /** + * Skip the test if using the specified database type + * + * @param string $type Database type + * @since 1.32 + */ + protected function markTestSkippedIfDbType( $type ) { + if ( $this->db->getType() === $type ) { + $this->markTestSkipped( "The $type database type isn't supported for this test" ); + } + } + /** * Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit. * @param string $buffer diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php index aebd0bf10e..3b270b31ad 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php @@ -13,9 +13,8 @@ class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase { public function setUp() { parent::setUp(); - if ( $this->db->getType() == 'postgres' ) { - $this->markTestSkipped( __CLASS__ . ' does not support postgres' ); - } + // FIXME: fails under postgres + $this->markTestSkippedIfDbType( 'postgres' ); } public function getSchemaOverrides( IMaintainableDatabase $db ) { diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php index c0673a10dc..391eec716a 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php @@ -16,9 +16,8 @@ class MediaWikiTestCaseSchema2Test extends MediaWikiTestCase { public function setUp() { parent::setUp(); - if ( $this->db->getType() == 'postgres' ) { - $this->markTestSkipped( __CLASS__ . ' does not support postgres' ); - } + // FIXME: fails under postgres + $this->markTestSkippedIfDbType( 'postgres' ); } public function testMediaWikiTestCaseSchemaTestOrder() {