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
Revision::getRevisionText( $row ), "getRevisionText" );
}
- # =================================================================================================================
+ # =========================================================================
/**
* @param string $text
*
* @return Revision
*/
- function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
+ function newTestRevision( $text, $title = "Test",
+ $model = CONTENT_MODEL_WIKITEXT, $format = null
+ ) {
if ( is_string( $title ) ) {
$title = Title::newFromText( $title );
}
$content = ContentHandler::makeContent( $text, $title, $model, $format );
$rev = new Revision(
- array(
+ [
'id' => 42,
'page' => 23,
'title' => $title,
'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" ],
+ ];
}
/**
}
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" ],
+ ];
}
/**
}
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' ],
+ ];
}
/**
}
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( 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' ) ),
- );
+ // 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' )
+ ],
+ [
+ serialize( 'hello world' ),
+ 'Dummy:Hello',
+ null,
+ null,
+ Revision::FOR_PUBLIC,
+ serialize( 'hello world' )
+ ],
+ ];
}
/**
* @dataProvider dataGetContent
* @covers Revision::getContent
*/
- public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+ public function testGetContent( $text, $title, $model, $format,
+ $audience, $expectedSerialization
+ ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$content = $rev->getContent( $audience );
- $this->assertEquals( $expectedSerialization, is_null( $content ) ? null : $content->serialize( $format ) );
+ $this->assertEquals(
+ $expectedSerialization,
+ is_null( $content ) ? null : $content->serialize( $format )
+ );
}
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 ],
+ ];
}
/**
}
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 ],
+ ];
}
/**
}
public function dataGetSha1() {
- return array(
- array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
- array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
- );
+ return [
+ [ "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ],
+ [
+ serialize( "hello world." ),
+ "testing",
+ Revision::base36Sha1( serialize( "hello world." ) )
+ ],
+ ];
}
/**
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' );
$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' );
$content = new RevisionTestModifyableContent( "foo" );
$rev = new Revision(
- array(
+ [
'id' => 42,
'page' => 23,
'title' => Title::newFromText( "testGetContentClone_dummy" ),
'length' => $content->getSize(),
'comment' => "testing",
'minor_edit' => false,
- )
+ ]
);
$content = $rev->getContent( Revision::RAW );
$content->setText( "bar" );
$content2 = $rev->getContent( Revision::RAW );
- $this->assertNotSame( $content, $content2, "expected a clone" ); // content is mutable, expect clone
- $this->assertEquals( "foo", $content2->getText() ); // clone should contain the original text
+ // content is mutable, expect clone
+ $this->assertNotSame( $content, $content2, "expected a clone" );
+ // clone should contain the original text
+ $this->assertEquals( "foo", $content2->getText() );
$content2->setText( "bla bla" );
$this->assertEquals( "bar", $content->getText() ); // clones should be independent
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 ) {