7 protected function setUp() {
13 'wgContLang' => Language::factory(
'en' ),
14 'wgLanguageCode' =>
'en',
15 'wgLegacyEncoding' =>
false,
16 'wgCompressRevisions' =>
false,
18 'wgContentHandlerTextFallback' =>
'ignore',
25 12313 =>
'Dummy_talk',
30 'wgNamespaceContentModels',
39 'testing' =>
'DummyContentHandlerForTesting',
40 'RevisionTestModifyableContent' =>
'RevisionTestModifyableContentHandler',
44 MWNamespace::getCanonicalNamespaces(
true ); # reset
namespace cache
51 MWNamespace::getCanonicalNamespaces(
true ); # reset
namespace cache
63 $row->old_text =
'This is a bunch of revision text.';
65 'This is a bunch of revision text.',
73 $this->checkPHPExtension(
'zlib' );
76 $row->old_flags =
'gzip';
77 $row->old_text = gzdeflate(
'This is a bunch of revision text.' );
79 'This is a bunch of revision text.',
88 $row->old_flags =
'utf-8';
89 $row->old_text =
"Wiki est l'\xc3\xa9cole superieur !";
90 $GLOBALS[
'wgLegacyEncoding'] =
'iso-8859-1';
92 "Wiki est l'\xc3\xa9cole superieur !",
101 $row->old_flags =
'';
102 $row->old_text =
"Wiki est l'\xe9cole superieur !";
103 $GLOBALS[
'wgLegacyEncoding'] =
'iso-8859-1';
105 "Wiki est l'\xc3\xa9cole superieur !",
113 $this->checkPHPExtension(
'zlib' );
116 $row->old_flags =
'gzip,utf-8';
117 $row->old_text = gzdeflate(
"Wiki est l'\xc3\xa9cole superieur !" );
118 $GLOBALS[
'wgLegacyEncoding'] =
'iso-8859-1';
120 "Wiki est l'\xc3\xa9cole superieur !",
128 $this->checkPHPExtension(
'zlib' );
131 $row->old_flags =
'gzip';
132 $row->old_text = gzdeflate(
"Wiki est l'\xe9cole superieur !" );
133 $GLOBALS[
'wgLegacyEncoding'] =
'iso-8859-1';
135 "Wiki est l'\xc3\xa9cole superieur !",
144 $row->old_text =
"Wiki est l'\xc3\xa9cole superieur !";
146 $this->assertTrue(
false !== strpos( $row->old_flags,
'utf-8' ),
147 "Flags should contain 'utf-8'" );
148 $this->assertFalse(
false !== strpos( $row->old_flags,
'gzip' ),
149 "Flags should not contain 'gzip'" );
150 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
151 $row->old_text,
"Direct check" );
152 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
160 $this->checkPHPExtension(
'zlib' );
161 $this->setMwGlobals(
'wgCompressRevisions',
true );
164 $row->old_text =
"Wiki est l'\xc3\xa9cole superieur !";
166 $this->assertTrue(
false !== strpos( $row->old_flags,
'utf-8' ),
167 "Flags should contain 'utf-8'" );
168 $this->assertTrue(
false !== strpos( $row->old_flags,
'gzip' ),
169 "Flags should contain 'gzip'" );
170 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
171 gzinflate( $row->old_text ),
"Direct check" );
172 $this->assertEquals(
"Wiki est l'\xc3\xa9cole superieur !",
176 # =========================================================================
189 if ( is_string( $title ) ) {
190 $title = Title::newFromText( $title );
201 'content' => $content,
202 'length' => $content->getSize(),
203 'comment' =>
"testing",
204 'minor_edit' =>
false,
206 'content_format' => $format,
218 [
serialize(
'hello world' ),
'Dummy:Hello',
null,
null,
"testing" ],
228 $rev = $this->newTestRevision( $text, $title, $model, $format );
230 $this->assertEquals( $expectedModel,
$rev->getContentModel() );
239 [
serialize(
'hello world' ),
'Dummy:Hello',
null,
null,
"testing" ],
249 $rev = $this->newTestRevision( $text, $title, $model, $format );
251 $this->assertEquals( $expectedFormat,
$rev->getContentFormat() );
257 [
'hello world',
'Help:Hello',
null,
null,
'WikitextContentHandler' ],
258 [
'hello world',
'User:hello/there.css',
null,
null,
'CssContentHandler' ],
259 [
serialize(
'hello world' ),
'Dummy:Hello',
null,
null,
'DummyContentHandlerForTesting' ],
269 $rev = $this->newTestRevision( $text, $title, $model, $format );
271 $this->assertEquals( $expectedClass, get_class(
$rev->getContentHandler() ) );
303 $audience, $expectedSerialization
305 $rev = $this->newTestRevision( $text, $title, $model, $format );
306 $content =
$rev->getContent( $audience );
309 $expectedSerialization,
310 is_null( $content ) ?
null : $content->serialize( $format )
317 [
serialize(
"hello world." ),
"testing", 12 ],
327 $rev = $this->newTestRevision( $text,
'RevisionTest_testGetSize', $model );
328 $this->assertEquals( $expected_size,
$rev->getSize() );
348 $rev = $this->newTestRevision( $text,
'RevisionTest_testGetSha1', $model );
349 $this->assertEquals( $expected_hash,
$rev->getSha1() );
357 'text' =>
'hello world.',
361 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
370 $title = Title::newFromText(
'RevisionTest_testConstructWithContent' );
376 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
394 'title' => Title::newFromText(
"testGetContentClone_dummy" ),
396 'content' => $content,
397 'length' => $content->getSize(),
398 'comment' =>
"testing",
399 'minor_edit' =>
false,
404 $content->setText(
"bar" );
408 $this->assertNotSame( $content, $content2,
"expected a clone" );
410 $this->assertEquals(
"foo", $content2->getText() );
412 $content2->setText(
"bla bla" );
413 $this->assertEquals(
"bar", $content->getText() );
428 $this->assertSame( $content, $content2 );
434 parent::__construct( $text,
"RevisionTestModifyableContent" );
446 $this->mText = $text;
457 $this->checkFormat( $format );
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
makeEmptyContent()
Creates an empty TextContent object.
unserializeContent( $text, $format=null)
Unserializes a Content object of the type supported by this ContentHandler.
testGetContentHandler( $text, $title, $model, $format, $expectedClass)
Database dataGetContentHandler Revision::getContentHandler.
testGetRevisionTextUtf8LegacyGzip()
Revision::getRevisionText.
testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization)
Database dataGetContent Revision::getContent.
testGetSize( $text, $model, $expected_size)
Revision::getSize Database dataGetSize.
testGetSha1( $text, $model, $expected_hash)
Revision::getSha1 Database dataGetSha1.
testGetContentFormat( $text, $title, $model, $format, $expectedFormat)
Database dataGetContentFormat Revision::getContentFormat.
testGetRevisionTextUtf8Legacy()
Revision::getRevisionText.
testGetRevisionTextGzip()
Revision::getRevisionText.
testConstructWithContent()
Revision::__construct.
testGetRevisionTextUtf8Native()
Revision::getRevisionText.
newTestRevision( $text, $title="Test", $model=CONTENT_MODEL_WIKITEXT, $format=null)
testGetContentUncloned()
Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
testCompressRevisionTextUtf8()
Revision::compressRevisionText.
testGetRevisionTextUtf8NativeGzip()
Revision::getRevisionText.
testGetContentClone()
Tests whether $rev->getContent() returns a clone when needed.
testGetContentModel( $text, $title, $model, $format, $expectedModel)
Database dataGetContentModel Revision::getContentModel.
testCompressRevisionTextUtf8Gzip()
Revision::compressRevisionText.
testConstructWithText()
Revision::__construct.
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Base content handler implementation for flat text contents.
Content object implementation for representing flat text.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
when a variable name is used in a function
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
const CONTENT_FORMAT_TEXT
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
you have access to all of the normal MediaWiki so you can get a DB use the cache