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 ) ) {
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 );
309 $expectedSerialization,
328 public function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
329 $this->hideDeprecated(
'Revision::getText' );
331 $rev = $this->newTestRevision( $text,
$title, $model, $format );
333 $this->assertEquals( $expectedText,
$rev->getText( $audience ) );
339 [
serialize(
"hello world." ),
"testing", 12 ],
349 $rev = $this->newTestRevision( $text,
'RevisionTest_testGetSize', $model );
350 $this->assertEquals( $expected_size,
$rev->getSize() );
370 $rev = $this->newTestRevision( $text,
'RevisionTest_testGetSha1', $model );
371 $this->assertEquals( $expected_hash,
$rev->getSha1() );
378 $this->hideDeprecated(
"Revision::getText" );
381 'text' =>
'hello world.',
385 $this->assertNotNull(
$rev->getText(),
'no content text' );
386 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
395 $this->hideDeprecated(
"Revision::getText" );
397 $title = Title::newFromText(
'RevisionTest_testConstructWithContent' );
403 $this->assertNotNull(
$rev->getText(),
'no content text' );
404 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
422 'title' => Title::newFromText(
"testGetContentClone_dummy" ),
426 'comment' =>
"testing",
427 'minor_edit' =>
false,
436 $this->assertNotSame(
$content, $content2,
"expected a clone" );
438 $this->assertEquals(
"foo", $content2->getText() );
440 $content2->setText(
"bla bla" );
441 $this->assertEquals(
"bar",
$content->getText() );
456 $this->assertSame(
$content, $content2 );
462 parent::__construct( $text,
"RevisionTestModifyableContent" );
474 $this->mText = $text;
485 $this->checkFormat( $format );
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.
testGetText( $text, $title, $model, $format, $audience, $expectedText)
Database dataGetText Revision::getText.
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 $row is usually an object from wfFetchRow(),...
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
when a variable name is used in a it is silently declared as a new local masking the global
const CONTENT_FORMAT_TEXT
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
you have access to all of the normal MediaWiki so you can get a DB use the cache