X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FGlobalFunctions%2FGlobalTest.php;h=ee4819fa5a66800d8ac1ccab97f86b00d173c02f;hp=5e54b8d4366ef68098906a0e5ce13d20acc07750;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hpb=2480aae0c97d822e10b50619e7b48b25c45af073 diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index 5e54b8d436..ee4819fa5a 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -473,26 +473,46 @@ class GlobalTest extends MediaWikiTestCase { ]; } + /** + * @covers ::wfMerge + */ + public function testMerge_worksWithLessParameters() { + $this->markTestSkippedIfNoDiff3(); + + $mergedText = null; + $successfulMerge = wfMerge( "old1\n\nold2", "old1\n\nnew2", "new1\n\nold2", $mergedText ); + + $mergedText = null; + $conflictingMerge = wfMerge( 'old', 'old and mine', 'old and yours', $mergedText ); + + $this->assertEquals( true, $successfulMerge ); + $this->assertEquals( false, $conflictingMerge ); + } + /** * @param string $old Text as it was in the database * @param string $mine Text submitted while user was editing * @param string $yours Text submitted by the user * @param bool $expectedMergeResult Whether the merge should be a success * @param string $expectedText Text after merge has been completed + * @param string $expectedMergeAttemptResult Diff3 output if conflicts occur * * @dataProvider provideMerge() * @group medium * @covers ::wfMerge */ - public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) { + public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText, + $expectedMergeAttemptResult ) { $this->markTestSkippedIfNoDiff3(); $mergedText = null; - $isMerged = wfMerge( $old, $mine, $yours, $mergedText ); + $attemptMergeResult = null; + $isMerged = wfMerge( $old, $mine, $yours, $mergedText, $mergeAttemptResult ); $msg = 'Merge should be a '; $msg .= $expectedMergeResult ? 'success' : 'failure'; $this->assertEquals( $expectedMergeResult, $isMerged, $msg ); + $this->assertEquals( $expectedMergeAttemptResult, $mergeAttemptResult ); if ( $isMerged ) { // Verify the merged text @@ -530,6 +550,9 @@ class GlobalTest extends MediaWikiTestCase { "one one one ONE ONE\n" . "\n" . "two two TWO TWO\n", // note: will always end in a newline + + // mergeAttemptResult: + "", ], // #1: conflict, fail @@ -552,6 +575,13 @@ class GlobalTest extends MediaWikiTestCase { // result: null, + + // mergeAttemptResult: + "1,3c\n" . + "one one one\n" . + "\n" . + "two two\n" . + ".\n", ], ]; } @@ -681,9 +711,9 @@ class GlobalTest extends MediaWikiTestCase { public function testWfMkdirParents() { // Should not return true if file exists instead of directory $fname = $this->getNewTempFile(); - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $ok = wfMkdirParents( $fname ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); $this->assertFalse( $ok ); } @@ -722,6 +752,9 @@ class GlobalTest extends MediaWikiTestCase { ); } + /** + * @covers ::wfMemcKey + */ public function testWfMemcKey() { $cache = ObjectCache::getLocalClusterInstance(); $this->assertEquals( @@ -730,6 +763,9 @@ class GlobalTest extends MediaWikiTestCase { ); } + /** + * @covers ::wfForeignMemcKey + */ public function testWfForeignMemcKey() { $cache = ObjectCache::getLocalClusterInstance(); $keyspace = $this->readAttribute( $cache, 'keyspace' ); @@ -739,6 +775,9 @@ class GlobalTest extends MediaWikiTestCase { ); } + /** + * @covers ::wfGlobalCacheKey + */ public function testWfGlobalCacheKey() { $cache = ObjectCache::getLocalClusterInstance(); $this->assertEquals(