X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FWikitextContentTest.php;h=d0996e3cfc91e530d0f4e93db1425583f9cd1e40;hb=e7720b8f8e09287384ddee271641d1b1721318bb;hp=f0d486ad07dd88a62196185b3c04e2e25bdb40fd;hpb=bacc11eb30ddf01624d5448f432b96afdae67c28;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index f0d486ad07..d0996e3cfc 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -24,41 +24,41 @@ more stuff } public static function dataGetParserOutput() { - return array( - array( + return [ + [ "WikitextContentTest_testGetParserOutput", CONTENT_MODEL_WIKITEXT, "hello ''world''\n", - "

hello world\n

" - ), + "

hello world\n

\n\n\n
" + ], // TODO: more...? - ); + ]; } public static function dataGetSecondaryDataUpdates() { - return array( - array( "WikitextContentTest_testGetSecondaryDataUpdates_1", + return [ + [ "WikitextContentTest_testGetSecondaryDataUpdates_1", CONTENT_MODEL_WIKITEXT, "hello ''world''\n", - array( - 'LinksUpdate' => array( + [ + 'LinksUpdate' => [ 'mRecursive' => true, - 'mLinks' => array() - ) - ) - ), - array( "WikitextContentTest_testGetSecondaryDataUpdates_2", + 'mLinks' => [] + ] + ] + ], + [ "WikitextContentTest_testGetSecondaryDataUpdates_2", CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n", - array( - 'LinksUpdate' => array( + [ + 'LinksUpdate' => [ 'mRecursive' => true, - 'mLinks' => array( - array( 'World_test_21344' => 0 ) - ) - ) - ) - ), + 'mLinks' => [ + [ 'World_test_21344' => 0 ] + ] + ] + ] + ], // TODO: more...? - ); + ]; } /** @@ -102,21 +102,21 @@ more stuff } public static function dataGetSection() { - return array( - array( WikitextContentTest::$sections, + return [ + [ self::$sections, "0", "Intro" - ), - array( WikitextContentTest::$sections, + ], + [ self::$sections, "2", "== test == just a test" - ), - array( WikitextContentTest::$sections, + ], + [ self::$sections, "8", false - ), - ); + ], + ]; } /** @@ -137,41 +137,41 @@ just a test" } public static function dataReplaceSection() { - return array( - array( WikitextContentTest::$sections, + return [ + [ self::$sections, "0", "No more", null, - trim( preg_replace( '/^Intro/sm', 'No more', WikitextContentTest::$sections ) ) - ), - array( WikitextContentTest::$sections, + trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) ) + ], + [ self::$sections, "", "No more", null, "No more" - ), - array( WikitextContentTest::$sections, + ], + [ self::$sections, "2", "== TEST ==\nmore fun", null, trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", - WikitextContentTest::$sections + self::$sections ) ) - ), - array( WikitextContentTest::$sections, + ], + [ self::$sections, "8", "No more", null, - WikitextContentTest::$sections - ), - array( WikitextContentTest::$sections, + self::$sections + ], + [ self::$sections, "new", "No more", "New", - trim( WikitextContentTest::$sections ) . "\n\n\n== New ==\n\nNo more" - ), - ); + trim( self::$sections ) . "\n\n\n== New ==\n\nNo more" + ], + ]; } /** @@ -196,122 +196,122 @@ just a test" } public static function dataPreSaveTransform() { - return array( - array( 'hello this is ~~~', + return [ + [ 'hello this is ~~~', "hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]", - ), - array( 'hello \'\'this\'\' is ~~~', + ], + [ 'hello \'\'this\'\' is ~~~', 'hello \'\'this\'\' is ~~~', - ), - array( // rtrim + ], + [ // rtrim " Foo \n ", " Foo", - ), - ); + ], + ]; } public static function dataPreloadTransform() { - return array( - array( + return [ + [ 'hello this is ~~~', "hello this is ~~~", - ), - array( + ], + [ 'hello \'\'this\'\' is foobar', 'hello \'\'this\'\' is bar', - ), - ); + ], + ]; } public static function dataGetRedirectTarget() { - return array( - array( '#REDIRECT [[Test]]', + return [ + [ '#REDIRECT [[Test]]', 'Test', - ), - array( '#REDIRECT Test', + ], + [ '#REDIRECT Test', null, - ), - array( '* #REDIRECT [[Test]]', + ], + [ '* #REDIRECT [[Test]]', null, - ), - ); + ], + ]; } public static function dataGetTextForSummary() { - return array( - array( "hello\nworld.", + return [ + [ "hello\nworld.", 16, 'hello world.', - ), - array( 'hello world.', + ], + [ 'hello world.', 8, 'hello...', - ), - array( '[[hello world]].', + ], + [ '[[hello world]].', 8, 'hel...', - ), - ); + ], + ]; } public static function dataIsCountable() { - return array( - array( '', + return [ + [ '', null, 'any', true - ), - array( 'Foo', + ], + [ 'Foo', null, 'any', true - ), - array( 'Foo', + ], + [ 'Foo', null, 'comma', false - ), - array( 'Foo, bar', + ], + [ 'Foo, bar', null, 'comma', true - ), - array( 'Foo', + ], + [ 'Foo', null, 'link', false - ), - array( 'Foo [[bar]]', + ], + [ 'Foo [[bar]]', null, 'link', true - ), - array( 'Foo', + ], + [ 'Foo', true, 'link', true - ), - array( 'Foo [[bar]]', + ], + [ 'Foo [[bar]]', false, 'link', false - ), - array( '#REDIRECT [[bar]]', + ], + [ '#REDIRECT [[bar]]', true, 'any', false - ), - array( '#REDIRECT [[bar]]', + ], + [ '#REDIRECT [[bar]]', true, 'comma', false - ), - array( '#REDIRECT [[bar]]', + ], + [ '#REDIRECT [[bar]]', true, 'link', false - ), - ); + ], + ]; } /** @@ -379,14 +379,14 @@ just a test" // Set up hook and its reporting variables $wikitext = null; $redirectTarget = null; - $this->mergeMwGlobalArrayValue( 'wgHooks', array( - 'InternalParseBeforeLinks' => array( + $this->mergeMwGlobalArrayValue( 'wgHooks', [ + 'InternalParseBeforeLinks' => [ function ( &$parser, &$text, &$stripState ) use ( &$wikitext, &$redirectTarget ) { $wikitext = $text; $redirectTarget = $parser->getOptions()->getRedirectTarget(); } - ) - ) ); + ] + ] ); // Test with non-redirect page $wikitext = false; @@ -433,26 +433,26 @@ just a test" } public static function dataEquals() { - return array( - array( new WikitextContent( "hallo" ), null, false ), - array( new WikitextContent( "hallo" ), new WikitextContent( "hallo" ), true ), - array( new WikitextContent( "hallo" ), new JavaScriptContent( "hallo" ), false ), - array( new WikitextContent( "hallo" ), new TextContent( "hallo" ), false ), - array( new WikitextContent( "hallo" ), new WikitextContent( "HALLO" ), false ), - ); + return [ + [ new WikitextContent( "hallo" ), null, false ], + [ new WikitextContent( "hallo" ), new WikitextContent( "hallo" ), true ], + [ new WikitextContent( "hallo" ), new JavaScriptContent( "hallo" ), false ], + [ new WikitextContent( "hallo" ), new TextContent( "hallo" ), false ], + [ new WikitextContent( "hallo" ), new WikitextContent( "HALLO" ), false ], + ]; } public static function dataGetDeletionUpdates() { - return array( - array( "WikitextContentTest_testGetSecondaryDataUpdates_1", + return [ + [ "WikitextContentTest_testGetSecondaryDataUpdates_1", CONTENT_MODEL_WIKITEXT, "hello ''world''\n", - array( 'LinksDeletionUpdate' => array() ) - ), - array( "WikitextContentTest_testGetSecondaryDataUpdates_2", + [ 'LinksDeletionUpdate' => [] ] + ], + [ "WikitextContentTest_testGetSecondaryDataUpdates_2", CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n", - array( 'LinksDeletionUpdate' => array() ) - ), + [ 'LinksDeletionUpdate' => [] ] + ], // @todo more...? - ); + ]; } }