Assert order of MediaWikiTestCaseSchema*Test execution
authoraddshore <addshorewiki@gmail.com>
Fri, 5 Jan 2018 15:44:36 +0000 (15:44 +0000)
committerAddshore <addshorewiki@gmail.com>
Mon, 8 Jan 2018 12:05:11 +0000 (12:05 +0000)
Make sure that we fail if these tests are run in the wrong order.
Essentially testing an assumption that currently holds true, but
could change in the future.

Change-Id: I8f33281d18f6f64e0e06c1b371b973542244dd24

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

index 4b0e0bf..6f94494 100644 (file)
@@ -8,6 +8,8 @@
  */
 class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase {
 
+       public static $hasRun = false;
+
        public function getSchemaOverrides() {
                return [
                        [ 'imagelinks', 'MediaWikiTestCaseTestTable' ],
@@ -15,6 +17,12 @@ class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase {
                ];
        }
 
+       public function testMediaWikiTestCaseSchemaTestOrder() {
+               // The test must be run before the second test
+               self::$hasRun = true;
+               $this->assertTrue( self::$hasRun );
+       }
+
        public function testSchemaExtension() {
                // make sure we can use the MediaWikiTestCaseTestTable table
 
index b1c65ee..74f053e 100644 (file)
  * that any schema modifications have been cleaned up between test cases.
  * As there seems to be no way to force execution order, we currently rely on
  * test classes getting run in anpha-numerical order.
+ * Order is checked by the testMediaWikiTestCaseSchemaTestOrder test in both classes.
  */
 class MediaWikiTestCaseSchema2Test extends MediaWikiTestCase {
 
+       public function testMediaWikiTestCaseSchemaTestOrder() {
+               // The first test must have run before this one
+               $this->assertTrue( MediaWikiTestCaseSchema1Test::$hasRun );
+       }
+
        public function testSchemaExtension() {
                // Make sure MediaWikiTestCaseTestTable created by MediaWikiTestCaseSchema1Test
                // was dropped before executing MediaWikiTestCaseSchema2Test.