From 43567e323958c247dd8da0d54ed82d6077f9244a Mon Sep 17 00:00:00 2001 From: addshore Date: Fri, 5 Jan 2018 15:44:36 +0000 Subject: [PATCH] Assert order of MediaWikiTestCaseSchema*Test execution 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 | 8 ++++++++ tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php index 4b0e0bf6d1..6f944946fa 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema1Test.php @@ -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 diff --git a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php index b1c65ee778..74f053eb3e 100644 --- a/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php +++ b/tests/phpunit/tests/MediaWikiTestCaseSchema2Test.php @@ -10,9 +10,15 @@ * 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. -- 2.20.1