// But frequently, this is used in fixture setup.
throw new MWException( "No namespace defaults to wikitext!" );
}
+
+ /**
+ * Check, if $wgDiff3 is set and ready to merge
+ * Will mark the calling test as skipped, if not ready
+ *
+ * @since 1.21
+ */
+ protected function checkHasDiff3() {
+ global $wgDiff3;
+
+ # This check may also protect against code injection in
+ # case of broken installations.
+ wfSuppressWarnings();
+ $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
+ wfRestoreWarnings();
+
+ if( !$haveDiff3 ) {
+ $this->markTestSkipped( "Skip test, since diff3 is not configured" );
+ }
+ }
}
return array_merge( $tests, $testsWithAdam, $testsWithBerta );
}
- function testHasValidDiff3() {
- global $wgDiff3;
-
- if ( !$wgDiff3 ) {
- $this->markTestSkipped( "Can't test conflict resolution because \$wgDiff3 is not configured" );
- } elseif ( !file_exists( $wgDiff3 ) ) {
- #XXX: this sucks, since it uses arcane internal knowledge about TextContentHandler::merge3 and wfMerge.
- $this->markTestSkipped( "Can't test conflict resolution because \$wgDiff3 is misconfigured: can't find $wgDiff3" );
- }
- $this->assertTrue( true );
- }
-
/**
- * @depend testHasValidDiff3
* @dataProvider provideAutoMerge
*/
public function testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit,
$expectedCode, $expectedText, $message = null
) {
+ $this->checkHasDiff3();
//create page
$ns = $this->getDefaultWikitextNS();
* @dataProvider provideMerge()
*/
public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) {
+ $this->checkHasDiff3();
+
$mergedText = null;
$isMerged = wfMerge( $old, $mine, $yours, $mergedText );
/* @todo FIXME: fix this!
public function testGetUndoText() {
- global $wgDiff3;
-
- wfSuppressWarnings();
- $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
- wfRestoreWarnings();
-
- if( !$haveDiff3 ) {
- $this->markTestSkipped( "diff3 not installed or not found" );
- return;
- }
+ $this->checkHasDiff3();
$text = "one";
$page = $this->createPage( "WikiPageTest_testGetUndoText", $text );
* @dataProvider dataMerge3
*/
public function testMerge3( $old, $mine, $yours, $expected ) {
- global $wgDiff3;
-
- if ( !$wgDiff3 ) {
- $this->markTestSkipped( "Can't test merge3(), since \$wgDiff3 is not configured" );
- }
-
- if ( !file_exists( $wgDiff3 ) ) {
- #XXX: this sucks, since it uses arcane internal knowledge about TextContentHandler::merge3 and wfMerge.
- $this->markTestSkipped( "Can't test merge3(), since \$wgDiff3 is misconfigured: can't find $wgDiff3" );
- }
+ $this->checkHasDiff3();
// test merge
$oldContent = new WikitextContent( $old );