* @group ContentHandler
*/
class RevisionTest extends MediaWikiTestCase {
+
protected function setUp() {
global $wgContLang;
);
MWNamespace::clearCaches();
- $wgContLang->resetNamespaces(); # reset namespace cache
+ // Reset namespace cache
+ $wgContLang->resetNamespaces();
}
- function tearDown() {
+ protected function tearDown() {
global $wgContLang;
MWNamespace::clearCaches();
- $wgContLang->resetNamespaces(); # reset namespace cache
+ // Reset namespace cache
+ $wgContLang->resetNamespaces();
parent::tearDown();
}
*
* @return Revision
*/
- function newTestRevision( $text, $title = "Test",
+ private function newTestRevision( $text, $title = "Test",
$model = CONTENT_MODEL_WIKITEXT, $format = null
) {
if ( is_string( $title ) ) {
return $rev;
}
- function dataGetContentModel() {
+ public function dataGetContentModel() {
// NOTE: we expect the help namespace to always contain wikitext
return [
[ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ],
$this->assertEquals( $expectedModel, $rev->getContentModel() );
}
- function dataGetContentFormat() {
+ public function dataGetContentFormat() {
// NOTE: we expect the help namespace to always contain wikitext
return [
[ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ],
$this->assertEquals( $expectedFormat, $rev->getContentFormat() );
}
- function dataGetContentHandler() {
+ public function dataGetContentHandler() {
// NOTE: we expect the help namespace to always contain wikitext
return [
[ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
$this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
}
- function dataGetContent() {
+ public function dataGetContent() {
// NOTE: we expect the help namespace to always contain wikitext
return [
[ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ],
]
);
+ /** @var RevisionTestModifyableContent $content */
$content = $rev->getContent( Revision::RAW );
$content->setText( "bar" );
+ /** @var RevisionTestModifyableContent $content2 */
$content2 = $rev->getContent( Revision::RAW );
// content is mutable, expect clone
$this->assertNotSame( $content, $content2, "expected a clone" );
$this->assertEquals( "foo", $content2->getText() );
$content2->setText( "bla bla" );
- $this->assertEquals( "bar", $content->getText() ); // clones should be independent
+ // clones should be independent
+ $this->assertEquals( "bar", $content->getText() );
}
/**
$this->assertSame( $content, $content2 );
}
}
-
-class RevisionTestModifyableContent extends TextContent {
- public function __construct( $text ) {
- parent::__construct( $text, "RevisionTestModifyableContent" );
- }
-
- public function copy() {
- return new RevisionTestModifyableContent( $this->mText );
- }
-
- public function getText() {
- return $this->mText;
- }
-
- public function setText( $text ) {
- $this->mText = $text;
- }
-}
-
-class RevisionTestModifyableContentHandler extends TextContentHandler {
-
- public function __construct() {
- parent::__construct( "RevisionTestModifyableContent", [ CONTENT_FORMAT_TEXT ] );
- }
-
- public function unserializeContent( $text, $format = null ) {
- $this->checkFormat( $format );
-
- return new RevisionTestModifyableContent( $text );
- }
-
- public function makeEmptyContent() {
- return new RevisionTestModifyableContent( '' );
- }
-}