Merge "createNoOpMock() method for PHPUnit tests"
[lhc/web/wiklou.git] / tests / phpunit / includes / diff / TextSlotDiffRendererTest.php
index e08efac..3eb1201 100644 (file)
@@ -9,14 +9,22 @@ class TextSlotDiffRendererTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideGetDiff
-        * @param Content|null $oldContent
-        * @param Content|null $newContent
+        * @param array|null $oldContentArgs To pass to makeContent() (if not null)
+        * @param array|null $newContentArgs
         * @param string|Exception $expectedResult
         * @throws Exception
         */
        public function testGetDiff(
-               Content $oldContent = null, Content $newContent = null, $expectedResult
+               array $oldContentArgs = null, array $newContentArgs = null, $expectedResult
        ) {
+               $this->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() );
                }
@@ -30,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' => [
@@ -63,13 +66,13 @@ 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" ),
+                               [ '', 'testing-nontext' ],
+                               [ "aaa\nbbb\nccc" ],
                                new ParameterTypeException( '$oldContent', 'TextContent|null' ),
                        ],
                        'non-text right content' => [
-                               $this->makeContent( "aaa\nbbb\nccc" ),
-                               $this->makeContent( '', 'testing-nontext' ),
+                               [ "aaa\nbbb\nccc" ],
+                               [ '', 'testing-nontext' ],
                                new ParameterTypeException( '$newContent', 'TextContent|null' ),
                        ],
                ];
@@ -84,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;
        }
@@ -108,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 );
        }