Go to the documentation of this file.
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',
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 ) ) {
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" ],
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
306 $content =
$rev->getContent( $audience );
309 $expectedSerialization,
310 is_null( $content ) ?
null : $content->serialize( $format )
317 [
serialize(
"hello world." ),
"testing", 12 ],
328 $this->assertEquals( $expected_size,
$rev->getSize() );
349 $this->assertEquals( $expected_hash,
$rev->getSha1() );
357 'text' =>
'hello world.',
361 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
376 $this->assertNotNull(
$rev->getContent(),
'no content object available' );
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 );
when a variable name is used in a function
testConstructWithContent()
Revision::__construct.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testGetSize( $text, $model, $expected_size)
Revision::getSize Database dataGetSize.
testGetRevisionTextUtf8Native()
Revision::getRevisionText.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
const CONTENT_MODEL_WIKITEXT
testGetRevisionTextUtf8NativeGzip()
Revision::getRevisionText.
you have access to all of the normal MediaWiki so you can get a DB use the cache
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
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
testGetRevisionTextUtf8LegacyGzip()
Revision::getRevisionText.
testGetRevisionText()
Revision::getRevisionText.
testConstructWithText()
Revision::__construct.
testCompressRevisionTextUtf8Gzip()
Revision::compressRevisionText.
namespace and then decline to actually register it file or subcat img or subcat $title
static compressRevisionText(&$text)
If $wgCompressRevisions is enabled, we will compress data.
const CONTENT_FORMAT_TEXT
when a variable name is used in a it is silently declared as a new masking the global
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
const CONTENT_FORMAT_WIKITEXT
newTestRevision( $text, $title="Test", $model=CONTENT_MODEL_WIKITEXT, $format=null)
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Base content handler implementation for flat text contents.
testGetContentModel( $text, $title, $model, $format, $expectedModel)
Database dataGetContentModel Revision::getContentModel.
Content object implementation for representing flat text.
testGetRevisionTextGzip()
Revision::getRevisionText.
testGetContentHandler( $text, $title, $model, $format, $expectedClass)
Database dataGetContentHandler Revision::getContentHandler.
makeEmptyContent()
Creates an empty TextContent object.
testGetRevisionTextUtf8Legacy()
Revision::getRevisionText.
testGetContentFormat( $text, $title, $model, $format, $expectedFormat)
Database dataGetContentFormat Revision::getContentFormat.
testGetContentUncloned()
Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
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
static getCanonicalNamespaces( $rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
static factory( $code)
Get a cached or new language object for a given language code.
const CONTENT_MODEL_JAVASCRIPT
testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization)
Database dataGetContent Revision::getContent.
testGetContentClone()
Tests whether $rev->getContent() returns a clone when needed.
unserializeContent( $text, $format=null)
Unserializes a Content object of the type supported by this ContentHandler.
testCompressRevisionTextUtf8()
Revision::compressRevisionText.
testGetSha1( $text, $model, $expected_hash)
Revision::getSha1 Database dataGetSha1.
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 content language as $wgContLang