X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fdiff%2FTextSlotDiffRendererTest.php;h=3eb12011d283c54b249df836d62425cad1cf237c;hb=eba2737ab9f27017bd269cf1b3129fe1cfffbb30;hp=ec45e29d672b7f0145ed466cd7ad33dcbe4d3b62;hpb=fede766fe9950e3a036c263bf17d19d31278221c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/diff/TextSlotDiffRendererTest.php b/tests/phpunit/includes/diff/TextSlotDiffRendererTest.php index ec45e29d67..3eb12011d2 100644 --- a/tests/phpunit/includes/diff/TextSlotDiffRendererTest.php +++ b/tests/phpunit/includes/diff/TextSlotDiffRendererTest.php @@ -1,5 +1,7 @@ mergeMwGlobalArrayValue( 'wgContentHandlers', [ + 'testing' => DummyContentHandlerForTesting::class, + 'testing-nontext' => DummyNonTextContentHandler::class, + ] ); + + $oldContent = $oldContentArgs ? self::makeContent( ...$oldContentArgs ) : null; + $newContent = $newContentArgs ? self::makeContent( ...$newContentArgs ) : null; + if ( $expectedResult instanceof Exception ) { $this->setExpectedException( get_class( $expectedResult ), $expectedResult->getMessage() ); } @@ -28,31 +38,26 @@ class TextSlotDiffRendererTest extends MediaWikiTestCase { $this->assertSame( $expectedResult, $plainDiff ); } - public function provideGetDiff() { - $this->mergeMwGlobalArrayValue( 'wgContentHandlers', [ - 'testing' => DummyContentHandlerForTesting::class, - 'testing-nontext' => DummyNonTextContentHandler::class, - ] ); - + public static function provideGetDiff() { return [ 'same text' => [ - $this->makeContent( "aaa\nbbb\nccc" ), - $this->makeContent( "aaa\nbbb\nccc" ), + [ "aaa\nbbb\nccc" ], + [ "aaa\nbbb\nccc" ], "", ], 'different text' => [ - $this->makeContent( "aaa\nbbb\nccc" ), - $this->makeContent( "aaa\nxxx\nccc" ), + [ "aaa\nbbb\nccc" ], + [ "aaa\nxxx\nccc" ], " aaa aaa\n-bbb+xxx\n ccc ccc", ], 'no right content' => [ - $this->makeContent( "aaa\nbbb\nccc" ), + [ "aaa\nbbb\nccc" ], null, "-aaa+ \n-bbb \n-ccc ", ], 'no left content' => [ null, - $this->makeContent( "aaa\nbbb\nccc" ), + [ "aaa\nbbb\nccc" ], "- +aaa\n +bbb\n +ccc", ], 'no content' => [ @@ -61,14 +66,14 @@ class TextSlotDiffRendererTest extends MediaWikiTestCase { new InvalidArgumentException( '$oldContent and $newContent cannot both be null' ), ], 'non-text left content' => [ - $this->makeContent( '', 'testing-nontext' ), - $this->makeContent( "aaa\nbbb\nccc" ), - new InvalidArgumentException( 'TextSlotDiffRenderer does not handle DummyNonTextContent' ), + [ '', 'testing-nontext' ], + [ "aaa\nbbb\nccc" ], + new ParameterTypeException( '$oldContent', 'TextContent|null' ), ], 'non-text right content' => [ - $this->makeContent( "aaa\nbbb\nccc" ), - $this->makeContent( '', 'testing-nontext' ), - new InvalidArgumentException( 'TextSlotDiffRenderer does not handle DummyNonTextContent' ), + [ "aaa\nbbb\nccc" ], + [ '', 'testing-nontext' ], + new ParameterTypeException( '$newContent', 'TextContent|null' ), ], ]; } @@ -82,7 +87,6 @@ class TextSlotDiffRendererTest extends MediaWikiTestCase { $slotDiffRenderer = new TextSlotDiffRenderer(); $slotDiffRenderer->setStatsdDataFactory( new NullStatsdDataFactory() ); $slotDiffRenderer->setLanguage( Language::factory( 'en' ) ); - $slotDiffRenderer->setWikiDiff2MovedParagraphDetectionCutoff( 0 ); $slotDiffRenderer->setEngine( TextSlotDiffRenderer::ENGINE_PHP ); return $slotDiffRenderer; } @@ -106,7 +110,7 @@ class TextSlotDiffRendererTest extends MediaWikiTestCase { * @param string $model * @return null|TextContent */ - private function makeContent( $str, $model = CONTENT_MODEL_TEXT ) { + private static function makeContent( $str, $model = CONTENT_MODEL_TEXT ) { return ContentHandler::makeContent( $str, null, $model ); }