Add MediaWikiTestCase::checkHasDiff3 and use it
Some tests can only passed, when diff3 is enabled on the wiki, when not the tests should marked as skipped. To avoid code duplicates inside the test folder for the check, if diff3 is enabled, the new function MediaWikiTestCase::checkHasDiff3 can be used. Change-Id: Ie765da49a4a1358da78a3506e38772d61bcd010c
This commit is contained in:
parent
c8867d3814
commit
9b3292e31a
5 changed files with 25 additions and 33 deletions
|
|
@ -789,4 +789,24 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
|
|||
// 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" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,25 +356,13 @@ hello
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -498,6 +498,8 @@ class GlobalTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideMerge()
|
||||
*/
|
||||
public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) {
|
||||
$this->checkHasDiff3();
|
||||
|
||||
$mergedText = null;
|
||||
$isMerged = wfMerge( $old, $mine, $yours, $mergedText );
|
||||
|
||||
|
|
|
|||
|
|
@ -704,16 +704,7 @@ more stuff
|
|||
|
||||
/* @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 );
|
||||
|
|
|
|||
|
|
@ -103,16 +103,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
|
|||
* @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 );
|
||||
|
|
|
|||
Loading…
Reference in a new issue