7 protected function setUp() {
14 'wgLanguageCode' =>
'en',
15 'wgLegacyEncoding' =>
false,
16 'wgCompressRevisions' =>
false,
18 'wgContentHandlerTextFallback' =>
'ignore',
25 12313 =>
'Dummy_talk',
30 'wgNamespaceContentModels',
39 'testing' =>
'DummyContentHandlerForTesting',
40 'RevisionTestModifyableContent' =>
'RevisionTestModifyableContentHandler',
45 $wgContLang->resetNamespaces(); # reset
namespace cache
52 $wgContLang->resetNamespaces(); # reset
namespace cache
63 $row->old_text =
'This is a bunch of revision text.';
65 'This is a bunch of revision text.',
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 !",
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 !",
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 !",
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" ],
230 $this->assertEquals( $expectedModel,
$rev->getContentModel() );
239 [
serialize(
'hello world' ),
'Dummy:Hello', null, null,
"testing" ],
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' ],
271 $this->assertEquals( $expectedClass, get_class(
$rev->getContentHandler() ) );
303 $audience, $expectedSerialization
309 $expectedSerialization,
333 $this->assertEquals( $expectedText,
$rev->getText( $audience ) );
339 [
serialize(
"hello world." ),
"testing", 12 ],
350 $this->assertEquals( $expected_size,
$rev->getSize() );
371 $this->assertEquals( $expected_hash,
$rev->getSha1() );
381 'text' =>
'hello world.',
385 $this->assertNotNull(
$rev->getText(),
'no content text' );
386 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
403 $this->assertNotNull(
$rev->getText(),
'no content text' );
404 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
426 'comment' =>
"testing",
427 'minor_edit' =>
false,
432 $content->setText(
"bar" );
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 getRevisionText($row, $prefix= 'old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow()...
const CONTENT_MODEL_WIKITEXT
testGetContentFormat($text, $title, $model, $format, $expectedFormat)
Database dataGetContentFormat Revision::getContentFormat.
testGetSha1($text, $model, $expected_hash)
Revision::getSha1 Database dataGetSha1.
testConstructWithText()
Revision::__construct.
testCompressRevisionTextUtf8Gzip()
Revision::compressRevisionText.
testGetContentModel($text, $title, $model, $format, $expectedModel)
Database dataGetContentModel Revision::getContentModel.
testGetContentUncloned()
Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
testGetRevisionTextGzip()
Revision::getRevisionText.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
when a variable name is used in a it is silently declared as a new local masking the global
when a variable name is used in a function
you have access to all of the normal MediaWiki so you can get a DB use the cache
const CONTENT_FORMAT_TEXT
testGetRevisionTextUtf8Legacy()
Revision::getRevisionText.
Content object implementation for representing flat text.
testGetRevisionTextUtf8Native()
Revision::getRevisionText.
unserializeContent($text, $format=null)
testGetRevisionTextUtf8NativeGzip()
Revision::getRevisionText.
testGetSize($text, $model, $expected_size)
Revision::getSize Database dataGetSize.
testCompressRevisionTextUtf8()
Revision::compressRevisionText.
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
testGetRevisionText()
Revision::getRevisionText.
namespace and then decline to actually register it file or subcat img or subcat $title
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
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
CONTENT_MODEL_JAVASCRIPT
Uploads have to be specially set up to be secure.
testGetContent($text, $title, $model, $format, $audience, $expectedSerialization)
Database dataGetContent Revision::getContent.
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
testGetContentHandler($text, $title, $model, $format, $expectedClass)
Database dataGetContentHandler Revision::getContentHandler.
testGetRevisionTextUtf8LegacyGzip()
Revision::getRevisionText.
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
getText($audience=self::FOR_PUBLIC, User $user=null)
Fetch revision text if it's available to the specified audience.
newTestRevision($text, $title="Test", $model=CONTENT_MODEL_WIKITEXT, $format=null)
Base content handler implementation for flat text contents.
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
testGetText($text, $title, $model, $format, $audience, $expectedText)
Database dataGetText Revision::getText.
static base36Sha1($text)
Get the base 36 SHA-1 value for a string of text.
const CONTENT_FORMAT_WIKITEXT
copy()
Return a copy of this Content object.
static factory($code)
Get a cached or new language object for a given language code.
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
testGetContentClone()
Tests whether $rev->getContent() returns a clone when needed.
testConstructWithContent()
Revision::__construct.