17 $this->tablesUsed[] =
'page';
18 $this->tablesUsed[] =
'revision';
22 $user->setName(
'127.0.0.1' );
25 $this->context->setTitle( Title::newFromText(
'Test' ) );
26 $this->context->setUser(
$user );
30 'wgTextModelsToParse' => [
35 'wgTidyConfig' => [
'driver' =>
'RemexHtml' ],
36 'wgCapitalLinks' =>
true,
59 'TextContentTest_testGetParserOutput',
61 "hello ''world'' & [[stuff]]\n",
"hello ''world'' & [[stuff]]",
75 $expectedFields =
null
82 $html = $po->getText();
83 $html = preg_replace(
'#<!--.*?-->#sm',
'',
$html );
85 $this->assertEquals( $expectedHtml, trim(
$html ) );
87 if ( $expectedFields ) {
88 foreach ( $expectedFields
as $field => $exp ) {
89 $f =
'get' . ucfirst( $field );
90 $v = call_user_func( [ $po,
$f ] );
92 if ( is_array( $exp ) ) {
95 $this->assertEquals( $exp, $v );
106 # 0: no signature resolution
116 # 2: newline normalization
117 "LF\n\nCRLF\r\n\r\nCR\r\rEND",
118 "LF\n\nCRLF\n\nCR\n\nEND",
128 $options = ParserOptions::newFromUserAndLang( $this->context->getUser(),
129 MediaWikiServices::getInstance()->getContentLanguage() );
133 $this->context->getTitle(),
134 $this->context->getUser(),
138 $this->assertEquals( $expected,
$content->getText() );
155 $options = ParserOptions::newFromUserAndLang( $this->context->getUser(),
156 MediaWikiServices::getInstance()->getContentLanguage() );
161 $this->assertEquals( $expected,
$content->getText() );
166 [
'#REDIRECT [[Test]]',
180 if ( is_null( $expected ) ) {
181 $this->assertNull(
$t,
"text should not have generated a redirect target: $text" );
183 $this->assertEquals( $expected,
$t->getPrefixedText() );
194 $this->assertEquals( !is_null( $expected ),
$content->isRedirect() );
221 $v =
$content->isCountable( $hasLinks, $this->context->getTitle() );
226 'isCountable() returned unexpected value ' . var_export( $v,
true )
227 .
' instead of ' . var_export( $expected,
true )
228 .
" in mode `$mode` for text \"$text\""
242 [
'[[hello world]].',
256 $this->assertEquals( $expected,
$content->getTextForSummary( $maxlength ) );
265 $this->assertEquals(
'hello world.',
$content->getTextForSearchIndex() );
275 $this->assertTrue(
$content->equals( $copy ),
'copy must be equal to original' );
276 $this->assertEquals(
'hello world.', $copy->getText() );
285 $this->assertEquals( 12,
$content->getSize() );
294 $this->assertEquals(
'hello world.',
$content->getText() );
303 $this->assertEquals(
'hello world.',
$content->getText() );
312 $this->assertEquals(
'hello world.',
$content->getWikitextForTransclusion() );
338 [
'hallo welt.',
false ],
349 $this->assertEquals( $empty,
$content->isEmpty() );
367 $this->assertEquals( $equal, $a->
equals( $b ) );
390 $title = $page->getTitle();
393 $page->doEditContent(
$content,
'' );
395 $updates =
$content->getDeletionUpdates( $page );
398 foreach ( $updates
as $update ) {
399 $class = get_class( $update );
400 $updates[$class] = $update;
403 foreach ( $expectedStuff
as $class => $fieldValues ) {
404 $this->assertArrayHasKey( $class, $updates,
"missing an update of type $class" );
406 $update = $updates[$class];
408 foreach ( $fieldValues
as $field =>
$value ) {
409 $v = $update->$field; #
if the field doesn
't exist, just crash and burn
410 $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
414 // make phpunit happy even if $expectedStuff was empty
415 $this->assertTrue( true );
418 public static function provideConvert() {
422 CONTENT_MODEL_WIKITEXT,
428 CONTENT_MODEL_WIKITEXT,
440 CONTENT_MODEL_JAVASCRIPT,
451 public function testConvert( $text, $model, $lossy, $expectedNative ) {
452 $content = $this->newContent( $text );
455 $converted = $content->convert( $model, $lossy );
457 if ( $expectedNative === false ) {
458 $this->assertFalse( $converted, "conversion to $model was expected to fail!" );
460 $this->assertInstanceOf( Content::class, $converted );
461 $this->assertEquals( $expectedNative, $converted->getText() );
469 public function testNormalizeLineEndings( $input, $expected ) {
470 $this->assertEquals( $expected, TextContent::normalizeLineEndings( $input ) );
473 public static function provideNormalizeLineEndings() {
494 public function testSerialize() {
495 $cnt = $this->newContent( 'testing
text' );
497 $this->assertSame( 'testing
text', $cnt->serialize() );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
WebRequest clone which takes values from a provided array.
Content for JavaScript pages.
static destroySingleton()
Destroy the current singleton instance.
Group all the pieces relevant to the context of a request into one instance.
ContentHandler Database ^— needed, because we do need the database to test link updates.
testGetContentHandler()
TextContent::getContentHandler.
testGetTextForSearchIndex()
TextContent::getTextForSearchIndex.
testGetModel()
TextContent::getModel.
testGetText()
TextContent::getText.
testGetNativeData()
TextContent::getNativeData.
testGetSize()
TextContent::getSize.
testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields=null)
dataGetParserOutput TextContent::getParserOutput
testPreloadTransform( $text, $expected)
dataPreloadTransform TextContent::preloadTransform
testCopy()
TextContent::copy.
static dataGetParserOutput()
testEquals(Content $a, Content $b=null, $equal=false)
dataEquals TextContent::equals
testGetWikitextForTransclusion()
TextContent::getWikitextForTransclusion.
testDeletionUpdates( $model, $text, $expectedStuff)
dataGetDeletionUpdates TextContent::getDeletionUpdates
testIsEmpty( $text, $empty)
dataIsEmpty TextContent::isEmpty
static dataGetRedirectTarget()
testIsRedirect( $text, $expected)
dataGetRedirectTarget TextContent::isRedirect
testGetRedirectTarget( $text, $expected)
dataGetRedirectTarget TextContent::getRedirectTarget
static dataGetDeletionUpdates()
testIsCountable( $text, $hasLinks, $mode, $expected)
dataIsCountable TextContent::isCountable
testGetTextForSummary( $text, $maxlength, $expected)
dataGetTextForSummary TextContent::getTextForSummary
static dataPreSaveTransform()
static dataPreloadTransform()
testPreSaveTransform( $text, $expected)
dataPreSaveTransform TextContent::preSaveTransform
static dataGetTextForSummary()
Content object implementation for representing flat text.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
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_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 true
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
return true to allow those checks to and false if checking is done & $user
processing should stop and the error should be shown to the user * false
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
Base interface for content objects.
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.