aboutsummaryrefslogtreecommitdiffstats
path: root/tests/parser
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@cscott.net>2020-08-17 23:41:34 -0400
committerC. Scott Ananian <cscott@cscott.net>2020-09-15 16:15:44 -0400
commitce663741bc06ff481df28c9c1618bbe885f5028b (patch)
treef8622a37ca3013eb66b22e859d30478b146024bb /tests/parser
parent1f5b2dc10545613da4e0ddfedff61717b54bb37b (diff)
downloadmediawikicore-ce663741bc06ff481df28c9c1618bbe885f5028b.tar.gz
mediawikicore-ce663741bc06ff481df28c9c1618bbe885f5028b.zip
Allow independent parser test files to (re)define articles w/ the same names
It leads to surprising results when the definitions in one parser test file leak into all the others. This can cause spurious test failures when you happen to have two extensions which define conflicting article fixtures, and prevents you from using parser tests to test patches like I50ff8a7b6be95901ebb14ffbe64940a0f499cfac, where you deliberately want to set up and test two different definitions for the same template name. Change-Id: I958c6305a95ca32418d83b7f33f7c180a3b370cd
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/ParserTestRunner.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php
index 9cb6a23b15fa..d3a86e98aea7 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -786,6 +786,9 @@ class ParserTestRunner {
}
}
+ // Clean up
+ $this->cleanupArticles( $testFileInfo['articles'] );
+
return $ok;
}
@@ -1543,6 +1546,23 @@ class ParserTestRunner {
}
/**
+ * Remove articles from the test DB. This prevents independent parser
+ * test files from having conflicts when they choose the same names
+ * for article or template test fixtures.
+ *
+ * @param array $articles Article info array from TestFileReader
+ */
+ public function cleanupArticles( $articles ) {
+ $user = RequestContext::getMain()->getUser();
+ foreach ( $articles as $info ) {
+ $name = self::chomp( $info['name'] );
+ $title = Title::newFromText( $name );
+ $page = WikiPage::factory( $title );
+ $page->doDeleteArticleReal( 'cleaning up', $user );
+ }
+ }
+
+ /**
* Insert a temporary test article
* @param string $name The title, including any prefix
* @param string $text The article text