Introduce MediaWikiTestCase::markTestSkippedIfDbType()
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 1 Aug 2018 07:19:10 +0000 (00:19 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 1 Aug 2018 07:19:10 +0000 (00:19 -0700)
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

tests/phpunit/MediaWikiTestCase.php
tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php
tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php

index db75bc0..382bf50 100644 (file)
@@ -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
index aebd0bf..3b270b3 100644 (file)
@@ -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 ) {
index c0673a1..391eec7 100644 (file)
@@ -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() {