X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FRevisionTest.php;h=767c963b66b32de1911f70b148e0c52d97d917a8;hb=f9f12ba25270cce567b696b79730511a6ea81797;hp=4623b3834127e91c2d65217cc91d4d4d1e9d0bcf;hpb=166191535f486569277e95b7e6a3850b5db6757d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index 4623b38341..767c963b66 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -9,36 +9,36 @@ class RevisionTest extends MediaWikiTestCase { parent::setUp(); - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgContLang' => Language::factory( 'en' ), 'wgLanguageCode' => 'en', 'wgLegacyEncoding' => false, 'wgCompressRevisions' => false, 'wgContentHandlerTextFallback' => 'ignore', - ) ); + ] ); $this->mergeMwGlobalArrayValue( 'wgExtraNamespaces', - array( + [ 12312 => 'Dummy', 12313 => 'Dummy_talk', - ) + ] ); $this->mergeMwGlobalArrayValue( 'wgNamespaceContentModels', - array( + [ 12312 => 'testing', - ) + ] ); $this->mergeMwGlobalArrayValue( 'wgContentHandlers', - array( + [ 'testing' => 'DummyContentHandlerForTesting', 'RevisionTestModifyableContent' => 'RevisionTestModifyableContentHandler', - ) + ] ); MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache @@ -193,7 +193,7 @@ class RevisionTest extends MediaWikiTestCase { $content = ContentHandler::makeContent( $text, $title, $model, $format ); $rev = new Revision( - array( + [ 'id' => 42, 'page' => 23, 'title' => $title, @@ -204,19 +204,19 @@ class RevisionTest extends MediaWikiTestCase { 'minor_edit' => false, 'content_format' => $format, - ) + ] ); return $rev; } function dataGetContentModel() { - //NOTE: we expect the help namespace to always contain wikitext - return array( - array( 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ), - array( 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ), - array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ), - ); + // NOTE: we expect the help namespace to always contain wikitext + return [ + [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ], + [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ], + [ serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ], + ]; } /** @@ -231,13 +231,13 @@ class RevisionTest extends MediaWikiTestCase { } function dataGetContentFormat() { - //NOTE: we expect the help namespace to always contain wikitext - return array( - array( 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ), - array( 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ), - array( 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ), - array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ), - ); + // NOTE: we expect the help namespace to always contain wikitext + return [ + [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ], + [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ], + [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ], + [ serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ], + ]; } /** @@ -252,12 +252,12 @@ class RevisionTest extends MediaWikiTestCase { } function dataGetContentHandler() { - //NOTE: we expect the help namespace to always contain wikitext - return array( - array( 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ), - array( 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ), - array( serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ), - ); + // NOTE: we expect the help namespace to always contain wikitext + return [ + [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ], + [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ], + [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ], + ]; } /** @@ -272,26 +272,26 @@ class RevisionTest extends MediaWikiTestCase { } function dataGetContent() { - //NOTE: we expect the help namespace to always contain wikitext - return array( - array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ), - array( + // NOTE: we expect the help namespace to always contain wikitext + return [ + [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ], + [ serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) - ), - array( + ], + [ serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) - ), - ); + ], + ]; } /** @@ -312,12 +312,12 @@ class RevisionTest extends MediaWikiTestCase { } function dataGetText() { - //NOTE: we expect the help namespace to always contain wikitext - return array( - array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ), - array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ), - array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ), - ); + // NOTE: we expect the help namespace to always contain wikitext + return [ + [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ], + [ serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ], + [ serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ], + ]; } /** @@ -333,24 +333,11 @@ class RevisionTest extends MediaWikiTestCase { $this->assertEquals( $expectedText, $rev->getText( $audience ) ); } - /** - * @group Database - * @dataProvider dataGetText - * @covers Revision::getRawText - */ - public function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) { - $this->hideDeprecated( 'Revision::getRawText' ); - - $rev = $this->newTestRevision( $text, $title, $model, $format ); - - $this->assertEquals( $expectedText, $rev->getRawText( $audience ) ); - } - public function dataGetSize() { - return array( - array( "hello world.", CONTENT_MODEL_WIKITEXT, 12 ), - array( serialize( "hello world." ), "testing", 12 ), - ); + return [ + [ "hello world.", CONTENT_MODEL_WIKITEXT, 12 ], + [ serialize( "hello world." ), "testing", 12 ], + ]; } /** @@ -364,14 +351,14 @@ class RevisionTest extends MediaWikiTestCase { } public function dataGetSha1() { - return array( - array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ), - array( + return [ + [ "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ], + [ serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) - ), - ); + ], + ]; } /** @@ -390,10 +377,10 @@ class RevisionTest extends MediaWikiTestCase { public function testConstructWithText() { $this->hideDeprecated( "Revision::getText" ); - $rev = new Revision( array( + $rev = new Revision( [ 'text' => 'hello world.', 'content_model' => CONTENT_MODEL_JAVASCRIPT - ) ); + ] ); $this->assertNotNull( $rev->getText(), 'no content text' ); $this->assertNotNull( $rev->getContent(), 'no content object available' ); @@ -409,9 +396,9 @@ class RevisionTest extends MediaWikiTestCase { $title = Title::newFromText( 'RevisionTest_testConstructWithContent' ); - $rev = new Revision( array( + $rev = new Revision( [ 'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ), - ) ); + ] ); $this->assertNotNull( $rev->getText(), 'no content text' ); $this->assertNotNull( $rev->getContent(), 'no content object available' ); @@ -429,7 +416,7 @@ class RevisionTest extends MediaWikiTestCase { $content = new RevisionTestModifyableContent( "foo" ); $rev = new Revision( - array( + [ 'id' => 42, 'page' => 23, 'title' => Title::newFromText( "testGetContentClone_dummy" ), @@ -438,7 +425,7 @@ class RevisionTest extends MediaWikiTestCase { 'length' => $content->getSize(), 'comment' => "testing", 'minor_edit' => false, - ) + ] ); $content = $rev->getContent( Revision::RAW ); @@ -491,7 +478,7 @@ class RevisionTestModifyableContent extends TextContent { class RevisionTestModifyableContentHandler extends TextContentHandler { public function __construct() { - parent::__construct( "RevisionTestModifyableContent", array( CONTENT_FORMAT_TEXT ) ); + parent::__construct( "RevisionTestModifyableContent", [ CONTENT_FORMAT_TEXT ] ); } public function unserializeContent( $text, $format = null ) {