Go to the documentation of this file.
16 $user->setName(
'127.0.0.1' );
20 'wgTextModelsToParse' =>
array(
26 'wgAlwaysUseTidy' =>
false,
31 $this->context->setUser(
$user );
41 'TextContentTest_testGetParserOutput',
43 "hello ''world'' & [[stuff]]\n",
"hello ''world'' & [[stuff]]",
60 $po = $content->getParserOutput(
$title );
62 $html = $po->getText();
63 $html = preg_replace(
'#<!--.*?-->#sm',
'',
$html );
65 $this->assertEquals( $expectedHtml, trim(
$html ) );
67 if ( $expectedFields ) {
68 foreach ( $expectedFields
as $field => $exp ) {
69 $f =
'get' . ucfirst( $field );
70 $v = call_user_func(
array( $po,
$f ) );
72 if ( is_array( $exp ) ) {
75 $this->assertEquals( $exp, $v );
86 #0: no signature resolution
108 $content = $content->preSaveTransform( $this->context->getTitle(), $this->context->getUser(),
$options );
110 $this->assertEquals( $expected, $content->getNativeData() );
131 $content = $content->preloadTransform( $this->context->getTitle(),
$options );
133 $this->assertEquals( $expected, $content->getNativeData() );
138 array(
'#REDIRECT [[Test]]',
150 $t = $content->getRedirectTarget();
152 if ( is_null( $expected ) ) {
153 $this->assertNull(
$t,
"text should not have generated a redirect target: $text" );
155 $this->assertEquals( $expected,
$t->getPrefixedText() );
166 $this->assertEquals( !is_null( $expected ), $content->isRedirect() );
224 $v = $content->isCountable( $hasLinks, $this->context->getTitle() );
226 $this->assertEquals( $expected, $v,
'isCountable() returned unexpected value ' . var_export( $v,
true )
227 .
' instead of ' . var_export( $expected,
true ) .
" in mode `$mode` for text \"$text\"" );
232 array(
"hello\nworld.",
236 array(
'hello world.',
240 array(
'[[hello world]].',
254 $this->assertEquals( $expected, $content->getTextForSummary( $maxlength ) );
261 $content = $this->
newContent(
'hello world.' );
263 $this->assertEquals(
'hello world.', $content->getTextForSearchIndex() );
270 $content = $this->
newContent(
'hello world.' );
271 $copy = $content->copy();
273 $this->assertTrue( $content->equals( $copy ),
'copy must be equal to original' );
274 $this->assertEquals(
'hello world.', $copy->getNativeData() );
281 $content = $this->
newContent(
'hello world.' );
283 $this->assertEquals( 12, $content->getSize() );
290 $content = $this->
newContent(
'hello world.' );
292 $this->assertEquals(
'hello world.', $content->getNativeData() );
299 $content = $this->
newContent(
'hello world.' );
301 $this->assertEquals(
'hello world.', $content->getWikitextForTransclusion() );
308 $content = $this->
newContent(
"hello world." );
317 $content = $this->
newContent(
"hello world." );
319 $this->assertEquals(
CONTENT_MODEL_TEXT, $content->getContentHandler()->getModelID() );
327 array(
'hallo welt.',
false ),
338 $this->assertEquals( $empty, $content->isEmpty() );
356 $this->assertEquals( $equal, $a->
equals( $b ) );
361 array(
"TextContentTest_testGetSecondaryDataUpdates_1",
365 array(
"TextContentTest_testGetSecondaryDataUpdates_2",
384 $page->doEditContent( $content,
'' );
386 $updates = $content->getDeletionUpdates( $page );
389 foreach ( $updates
as $update ) {
390 $class = get_class( $update );
391 $updates[$class] = $update;
394 if ( !$expectedStuff ) {
395 $this->assertTrue(
true );
399 foreach ( $expectedStuff
as $class => $fieldValues ) {
400 $this->assertArrayHasKey( $class, $updates,
"missing an update of type $class" );
402 $update = $updates[$class];
404 foreach ( $fieldValues
as $field =>
$value ) {
405 $v = $update->$field; #
if the field doesn
't exist, just crash and burn
406 $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
410 $page->doDeleteArticle( '' );
413 public static function provideConvert() {
417 CONTENT_MODEL_WIKITEXT,
423 CONTENT_MODEL_WIKITEXT,
435 CONTENT_MODEL_JAVASCRIPT,
446 public function testConvert( $text, $model, $lossy, $expectedNative ) {
447 $content = $this->newContent( $text );
449 $converted = $content->convert( $model, $lossy );
451 if ( $expectedNative === false ) {
452 $this->assertFalse( $converted, "conversion to $model was expected to fail!" );
454 $this->assertInstanceOf( 'Content', $converted );
455 $this->assertEquals( $expectedNative, $converted->getNativeData() );
static dataGetTextForSummary()
testGetTextForSummary( $text, $maxlength, $expected)
@dataProvider dataGetTextForSummary @covers TextContent::getTextForSummary
WebRequest clone which takes values from a provided array.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
testPreSaveTransform( $text, $expected)
@dataProvider dataPreSaveTransform @covers TextContent::preSaveTransform
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
testPreloadTransform( $text, $expected)
@dataProvider dataPreloadTransform @covers TextContent::preloadTransform
static dataGetRedirectTarget()
@group ContentHandler @group Database ^— needed, because we do need the database to test link updates
testIsCountable( $text, $hasLinks, $mode, $expected)
@dataProvider dataIsCountable @group Database @covers TextContent::isCountable
testGetNativeData()
@covers TextContent::getNativeData
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
const CONTENT_MODEL_WIKITEXT
static dataGetParserOutput()
testEquals(Content $a, Content $b=null, $equal=false)
@dataProvider dataEquals @covers TextContent::equals
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields=null)
@dataProvider dataGetParserOutput @covers TextContent::getParserOutput
testGetModel()
@covers TextContent::getModel
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
testGetTextForSearchIndex()
@covers TextContent::getTextForSearchIndex
static dataPreloadTransform()
when a variable name is used in a it is silently declared as a new masking the global
Group all the pieces relevant to the context of a request into one instance.
Content object for wiki text pages.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Content for JavaScript pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
testIsEmpty( $text, $empty)
@dataProvider dataIsEmpty @covers TextContent::isEmpty
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.
testGetRedirectTarget( $text, $expected)
@dataProvider dataGetRedirectTarget @covers TextContent::getRedirectTarget
presenting them properly to the user as errors is done by the caller $title
static dataPreSaveTransform()
testGetSize()
@covers TextContent::getSize
static dataGetDeletionUpdates()
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Content object implementation for representing flat text.
Base interface for content objects.
testGetWikitextForTransclusion()
@covers TextContent::getWikitextForTransclusion
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const CONTENT_MODEL_JAVASCRIPT
testDeletionUpdates( $title, $model, $text, $expectedStuff)
@dataProvider dataGetDeletionUpdates @covers TextContent::getDeletionUpdates
testCopy()
@covers TextContent::copy
testGetContentHandler()
@covers TextContent::getContentHandler
testIsRedirect( $text, $expected)
@dataProvider dataGetRedirectTarget @covers TextContent::isRedirect