Only use "*Test.php" for actual PHPUnit tests
authorAryeh Gregor <ayg@aryeh.name>
Thu, 9 Aug 2018 14:38:13 +0000 (17:38 +0300)
committerAryeh Gregor <ayg@aryeh.name>
Wed, 3 Oct 2018 17:22:22 +0000 (20:22 +0300)
Otherwise I get errors every time I try to run PHPUnit on includes/ or
includes/parser, because it tries to run ParserIntegrationTest.php and
fails.  Apparently the <exclude> in suite.xml doesn't work if PHPUnit is
invoked on a directory.

Bug: T201278
Change-Id: I7d09576bee2705d8516152e8fa671da8dac40233

tests/common/TestsAutoLoader.php
tests/phpunit/includes/parser/ParserIntegrationTest.php [deleted file]
tests/phpunit/suite.xml
tests/phpunit/suites/ParserIntegrationTest.php [new file with mode: 0644]

index 0cb042a..d864fc0 100644 (file)
@@ -126,7 +126,7 @@ $wgAutoloadClasses += [
        'WikiPageDbTestBase' => "$testDir/phpunit/includes/page/WikiPageDbTestBase.php",
 
        # tests/phpunit/includes/parser
-       'ParserIntegrationTest' => "$testDir/phpunit/includes/parser/ParserIntegrationTest.php",
+       'ParserIntegrationTest' => "$testDir/phpunit/suites/ParserIntegrationTest.php",
 
        # tests/phpunit/includes/password
        'PasswordTestCase' => "$testDir/phpunit/includes/password/PasswordTestCase.php",
diff --git a/tests/phpunit/includes/parser/ParserIntegrationTest.php b/tests/phpunit/includes/parser/ParserIntegrationTest.php
deleted file mode 100644 (file)
index 91653b5..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-use Wikimedia\ScopedCallback;
-
-/**
- * This is the TestCase subclass for running a single parser test via the
- * ParserTestRunner integration test system.
- *
- * Note: the following groups are not used by PHPUnit.
- * The list in ParserTestFileSuite::__construct() is used instead.
- *
- * @group large
- * @group Database
- * @group Parser
- * @group ParserTests
- *
- * @covers Parser
- * @covers BlockLevelPass
- * @covers CoreParserFunctions
- * @covers CoreTagHooks
- * @covers Sanitizer
- * @covers Preprocessor
- * @covers Preprocessor_DOM
- * @covers Preprocessor_Hash
- * @covers DateFormatter
- * @covers LinkHolderArray
- * @covers StripState
- * @covers ParserOptions
- * @covers ParserOutput
- */
-class ParserIntegrationTest extends PHPUnit\Framework\TestCase {
-
-       use MediaWikiCoversValidator;
-
-       /** @var array */
-       private $ptTest;
-
-       /** @var ParserTestRunner */
-       private $ptRunner;
-
-       /** @var ScopedCallback */
-       private $ptTeardownScope;
-
-       public function __construct( $runner, $fileName, $test ) {
-               parent::__construct( 'testParse', [ '[details omitted]' ],
-                       basename( $fileName ) . ': ' . $test['desc'] );
-               $this->ptTest = $test;
-               $this->ptRunner = $runner;
-       }
-
-       public function testParse() {
-               $this->ptRunner->getRecorder()->setTestCase( $this );
-               $result = $this->ptRunner->runTest( $this->ptTest );
-               $this->assertEquals( $result->expected, $result->actual );
-       }
-
-       public function setUp() {
-               $this->ptTeardownScope = $this->ptRunner->staticSetup();
-       }
-
-       public function tearDown() {
-               if ( $this->ptTeardownScope ) {
-                       ScopedCallback::consume( $this->ptTeardownScope );
-               }
-       }
-}
index e125b8a..a7d5001 100644 (file)
@@ -20,8 +20,6 @@
        <testsuites>
                <testsuite name="includes">
                        <directory>includes</directory>
-                       <!-- Parser tests must be invoked via their suite -->
-                       <exclude>includes/parser/ParserIntegrationTest.php</exclude>
                </testsuite>
                <testsuite name="languages">
                        <directory>languages</directory>
diff --git a/tests/phpunit/suites/ParserIntegrationTest.php b/tests/phpunit/suites/ParserIntegrationTest.php
new file mode 100644 (file)
index 0000000..91653b5
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+use Wikimedia\ScopedCallback;
+
+/**
+ * This is the TestCase subclass for running a single parser test via the
+ * ParserTestRunner integration test system.
+ *
+ * Note: the following groups are not used by PHPUnit.
+ * The list in ParserTestFileSuite::__construct() is used instead.
+ *
+ * @group large
+ * @group Database
+ * @group Parser
+ * @group ParserTests
+ *
+ * @covers Parser
+ * @covers BlockLevelPass
+ * @covers CoreParserFunctions
+ * @covers CoreTagHooks
+ * @covers Sanitizer
+ * @covers Preprocessor
+ * @covers Preprocessor_DOM
+ * @covers Preprocessor_Hash
+ * @covers DateFormatter
+ * @covers LinkHolderArray
+ * @covers StripState
+ * @covers ParserOptions
+ * @covers ParserOutput
+ */
+class ParserIntegrationTest extends PHPUnit\Framework\TestCase {
+
+       use MediaWikiCoversValidator;
+
+       /** @var array */
+       private $ptTest;
+
+       /** @var ParserTestRunner */
+       private $ptRunner;
+
+       /** @var ScopedCallback */
+       private $ptTeardownScope;
+
+       public function __construct( $runner, $fileName, $test ) {
+               parent::__construct( 'testParse', [ '[details omitted]' ],
+                       basename( $fileName ) . ': ' . $test['desc'] );
+               $this->ptTest = $test;
+               $this->ptRunner = $runner;
+       }
+
+       public function testParse() {
+               $this->ptRunner->getRecorder()->setTestCase( $this );
+               $result = $this->ptRunner->runTest( $this->ptTest );
+               $this->assertEquals( $result->expected, $result->actual );
+       }
+
+       public function setUp() {
+               $this->ptTeardownScope = $this->ptRunner->staticSetup();
+       }
+
+       public function tearDown() {
+               if ( $this->ptTeardownScope ) {
+                       ScopedCallback::consume( $this->ptTeardownScope );
+               }
+       }
+}