Go to the documentation of this file.
17 $this->tablesUsed[] =
'page';
18 $this->tablesUsed[] =
'revision';
22 $user->setName(
'127.0.0.1' );
26 $this->context->setUser(
$user );
30 'wgTextModelsToParse' => [
35 'wgTidyConfig' => [
'driver' =>
'RemexHtml' ],
36 'wgCapitalLinks' =>
true,
55 'TextContentTest_testGetParserOutput',
57 "hello ''world'' & [[stuff]]\n",
"hello ''world'' & [[stuff]]",
71 $expectedFields =
null
78 $html = $po->getText();
79 $html = preg_replace(
'#<!--.*?-->#sm',
'',
$html );
81 $this->assertEquals( $expectedHtml, trim(
$html ) );
83 if ( $expectedFields ) {
84 foreach ( $expectedFields
as $field => $exp ) {
85 $f =
'get' . ucfirst( $field );
86 $v = call_user_func( [ $po, $f ] );
88 if ( is_array( $exp ) ) {
91 $this->assertEquals( $exp, $v );
102 # 0: no signature resolution
112 # 2: newline normalization
113 "LF\n\nCRLF\r\n\r\nCR\r\rEND",
114 "LF\n\nCRLF\n\nCR\n\nEND",
125 MediaWikiServices::getInstance()->getContentLanguage() );
129 $this->context->getTitle(),
130 $this->context->getUser(),
134 $this->assertEquals( $expected,
$content->getNativeData() );
152 MediaWikiServices::getInstance()->getContentLanguage() );
157 $this->assertEquals( $expected,
$content->getNativeData() );
162 [
'#REDIRECT [[Test]]',
176 if ( is_null( $expected ) ) {
177 $this->assertNull(
$t,
"text should not have generated a redirect target: $text" );
179 $this->assertEquals( $expected,
$t->getPrefixedText() );
190 $this->assertEquals( !is_null( $expected ),
$content->isRedirect() );
217 $v =
$content->isCountable( $hasLinks, $this->context->getTitle() );
222 'isCountable() returned unexpected value ' . var_export( $v,
true )
223 .
' instead of ' . var_export( $expected,
true )
224 .
" in mode `$mode` for text \"$text\""
238 [
'[[hello world]].',
252 $this->assertEquals( $expected,
$content->getTextForSummary( $maxlength ) );
261 $this->assertEquals(
'hello world.',
$content->getTextForSearchIndex() );
271 $this->assertTrue(
$content->equals( $copy ),
'copy must be equal to original' );
272 $this->assertEquals(
'hello world.', $copy->getNativeData() );
281 $this->assertEquals( 12,
$content->getSize() );
290 $this->assertEquals(
'hello world.',
$content->getNativeData() );
299 $this->assertEquals(
'hello world.',
$content->getWikitextForTransclusion() );
325 [
'hallo welt.',
false ],
336 $this->assertEquals( $empty,
$content->isEmpty() );
354 $this->assertEquals( $equal, $a->
equals( $b ) );
377 $title = $page->getTitle();
380 $page->doEditContent(
$content,
'' );
382 $updates =
$content->getDeletionUpdates( $page );
385 foreach ( $updates
as $update ) {
386 $class = get_class( $update );
387 $updates[$class] = $update;
390 foreach ( $expectedStuff
as $class => $fieldValues ) {
391 $this->assertArrayHasKey( $class, $updates,
"missing an update of type $class" );
393 $update = $updates[$class];
395 foreach ( $fieldValues
as $field =>
$value ) {
396 $v = $update->$field; #
if the field doesn
't exist, just crash and burn
397 $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" );
401 // make phpunit happy even if $expectedStuff was empty
402 $this->assertTrue( true );
405 public static function provideConvert() {
409 CONTENT_MODEL_WIKITEXT,
415 CONTENT_MODEL_WIKITEXT,
427 CONTENT_MODEL_JAVASCRIPT,
438 public function testConvert( $text, $model, $lossy, $expectedNative ) {
439 $content = $this->newContent( $text );
441 $converted = $content->convert( $model, $lossy );
443 if ( $expectedNative === false ) {
444 $this->assertFalse( $converted, "conversion to $model was expected to fail!" );
446 $this->assertInstanceOf( Content::class, $converted );
447 $this->assertEquals( $expectedNative, $converted->getNativeData() );
455 public function testNormalizeLineEndings( $input, $expected ) {
456 $this->assertEquals( $expected, TextContent::normalizeLineEndings( $input ) );
459 public static function provideNormalizeLineEndings() {
static dataGetTextForSummary()
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
testGetTextForSummary( $text, $maxlength, $expected)
dataGetTextForSummary 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)
dataPreSaveTransform TextContent::preSaveTransform
processing should stop and the error should be shown to the user * false
testPreloadTransform( $text, $expected)
dataPreloadTransform TextContent::preloadTransform
static dataGetRedirectTarget()
ContentHandler Database ^— needed, because we do need the database to test link updates.
testIsCountable( $text, $hasLinks, $mode, $expected)
dataIsCountable TextContent::isCountable
testGetNativeData()
TextContent::getNativeData.
const CONTENT_MODEL_WIKITEXT
static dataGetParserOutput()
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
testEquals(Content $a, Content $b=null, $equal=false)
dataEquals TextContent::equals
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
namespace and then decline to actually register it file or subcat img or subcat $title
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields=null)
dataGetParserOutput TextContent::getParserOutput
testGetModel()
TextContent::getModel.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
testGetTextForSearchIndex()
TextContent::getTextForSearchIndex.
static dataPreloadTransform()
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.
testIsEmpty( $text, $empty)
dataIsEmpty TextContent::isEmpty
equals(Content $that=null)
Returns true if this Content objects is conceptually equivalent to the given Content object.
testGetRedirectTarget( $text, $expected)
dataGetRedirectTarget TextContent::getRedirectTarget
static dataPreSaveTransform()
testGetSize()
TextContent::getSize.
testDeletionUpdates( $model, $text, $expectedStuff)
dataGetDeletionUpdates TextContent::getDeletionUpdates
static dataGetDeletionUpdates()
Content object implementation for representing flat text.
Base interface for content objects.
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
testGetWikitextForTransclusion()
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
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
const CONTENT_MODEL_JAVASCRIPT
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 MediaWikiServices
testCopy()
TextContent::copy.
static destroySingleton()
Destroy the current singleton instance.
testGetContentHandler()
TextContent::getContentHandler.
testIsRedirect( $text, $expected)
dataGetRedirectTarget TextContent::isRedirect