X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FWikitextContentHandlerTest.php;h=9d4abe857dc8581353108335258c3368bbf0c806;hb=add1ebe2ab7cbbaf27f8f60a2d0b05769dff71a2;hp=38fb57330c325ae912780c2468a7f69d0db3853b;hpb=b2645d82849ca74b0e6b8df6a3e28e81d0561a58;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php index 38fb57330c..9d4abe857d 100644 --- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php +++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php @@ -64,11 +64,11 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { } public static function dataIsSupportedFormat() { - return array( - array( null, true ), - array( CONTENT_FORMAT_WIKITEXT, true ), - array( 99887766, false ), - ); + return [ + [ null, true ], + [ CONTENT_FORMAT_WIKITEXT, true ], + [ 99887766, false ], + ]; } /** @@ -91,20 +91,20 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { } public static function provideMakeRedirectContent() { - return array( - array( 'Hello', '#REDIRECT [[Hello]]' ), - array( 'Template:Hello', '#REDIRECT [[Template:Hello]]' ), - array( 'Hello#section', '#REDIRECT [[Hello#section]]' ), - array( 'user:john_doe#section', '#REDIRECT [[User:John doe#section]]' ), - array( 'MEDIAWIKI:FOOBAR', '#REDIRECT [[MediaWiki:FOOBAR]]' ), - array( 'Category:Foo', '#REDIRECT [[:Category:Foo]]' ), - array( Title::makeTitle( NS_MAIN, 'en:Foo' ), '#REDIRECT [[en:Foo]]' ), - array( Title::makeTitle( NS_MAIN, 'Foo', '', 'en' ), '#REDIRECT [[:en:Foo]]' ), - array( + return [ + [ 'Hello', '#REDIRECT [[Hello]]' ], + [ 'Template:Hello', '#REDIRECT [[Template:Hello]]' ], + [ 'Hello#section', '#REDIRECT [[Hello#section]]' ], + [ 'user:john_doe#section', '#REDIRECT [[User:John doe#section]]' ], + [ 'MEDIAWIKI:FOOBAR', '#REDIRECT [[MediaWiki:FOOBAR]]' ], + [ 'Category:Foo', '#REDIRECT [[:Category:Foo]]' ], + [ Title::makeTitle( NS_MAIN, 'en:Foo' ), '#REDIRECT [[en:Foo]]' ], + [ Title::makeTitle( NS_MAIN, 'Foo', '', 'en' ), '#REDIRECT [[:en:Foo]]' ], + [ Title::makeTitle( NS_MAIN, 'Bar', 'fragment', 'google' ), '#REDIRECT [[google:Bar#fragment]]' - ), - ); + ], + ]; } /** @@ -115,9 +115,14 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { $this->assertEquals( $supported, $this->handler->isSupportedFormat( $format ) ); } + public function testSupportsDirectEditing() { + $handler = new WikiTextContentHandler(); + $this->assertTrue( $handler->supportsDirectEditing(), 'direct editing is supported' ); + } + public static function dataMerge3() { - return array( - array( + return [ + [ "first paragraph second paragraph\n", @@ -133,9 +138,9 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { "FIRST paragraph SECOND paragraph\n", - ), + ], - array( "first paragraph + [ "first paragraph second paragraph\n", "Bla bla\n", @@ -143,8 +148,8 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { "Blubberdibla\n", false, - ), - ); + ], + ]; } /** @@ -152,7 +157,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { * @covers WikitextContentHandler::merge3 */ public function testMerge3( $old, $mine, $yours, $expected ) { - $this->checkHasDiff3(); + $this->markTestSkippedIfNoDiff3(); // test merge $oldContent = new WikitextContent( $old ); @@ -165,29 +170,29 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { } public static function dataGetAutosummary() { - return array( - array( + return [ + [ 'Hello there, world!', '#REDIRECT [[Foo]]', 0, '/^Redirected page .*Foo/' - ), + ], - array( + [ null, 'Hello world!', EDIT_NEW, '/^Created page .*Hello/' - ), + ], - array( + [ 'Hello there, world!', '', 0, '/^Blanked/' - ), + ], - array( + [ 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet @@ -195,15 +200,15 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { 'Hello world!', 0, '/^Replaced .*Hello/' - ), + ], - array( + [ 'foo', 'bar', 0, '/^$/' - ), - ); + ], + ]; } /** @@ -238,4 +243,20 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { ) { } */ + + public function testDataIndexFieldsFile() { + $mockEngine = $this->getMock( 'SearchEngine' ); + $title = Title::newFromText( 'Somefile.jpg', NS_FILE ); + $page = new WikiPage( $title ); + + $handler = $this->getMockBuilder( WikitextContentHandler::class ) + ->disableOriginalConstructor() + ->setMethods( [ 'getFileText' ] ) + ->getMock(); + $handler->method( 'getFileText' )->will( $this->returnValue( 'This is file content' ) ); + + $data = $handler->getDataForSearchIndex( $page, new ParserOutput(), $mockEngine ); + $this->assertArrayHasKey( 'file_text', $data ); + $this->assertEquals( 'This is file content', $data['file_text'] ); + } }