Go to the documentation of this file.
19 $extracted = EditPage::extractSectionTitle(
$section );
20 $this->assertEquals(
$title, $extracted );
26 "== Test ==\n\nJust a test section.",
30 "An initial section, no header.",
34 "An initial section with a fake heder (bug 32617)\n\n== Test == ??\nwtf",
38 "== Section ==\nfollowed by a fake == Non-section == ??\nnoooo",
42 "== Section== \t\r\n followed by whitespace (bug 35051)",
51 $dbw->update(
'revision',
64 return $this->assertEquals( rtrim( $expected ), rtrim( $actual ), $msg );
92 $expectedCode = EditPage::AS_OK, $expectedText =
null, $message =
null
94 if ( is_string(
$title ) ) {
99 if ( is_string(
$user ) ) {
102 if (
$user->getId() === 0 ) {
103 $user->addToDatabase();
109 if ( $baseText !==
null ) {
111 $page->doEditContent( $content,
"base text for test" );
118 # EditPage rtrim() the user input, so we alter our expected text
123 if (
$user ==
null ) {
129 if ( !isset( $edit[
'wpEditToken'] ) ) {
130 $edit[
'wpEditToken'] =
$user->getEditToken();
133 if ( !isset( $edit[
'wpEdittime'] ) ) {
134 $edit[
'wpEdittime'] = $page->exists() ? $page->getTimestamp() :
'';
137 if ( !isset( $edit[
'wpStarttime'] ) ) {
144 $ep->setContextTitle(
$title );
145 $ep->importFormData( $req );
147 $bot = isset( $edit[
'bot'] ) ? (bool)$edit[
'bot'] :
false;
152 $status = $ep->internalAttemptSave(
$result, $bot );
154 if ( $expectedCode !==
null ) {
156 $this->assertEquals( $expectedCode, $status->value,
157 "Expected result code mismatch. $message" );
162 if ( $expectedText !==
null ) {
164 $content = $page->getContent();
167 # EditPage rtrim() the user input, so we alter our expected text
170 "Expected article text mismatch. $message" );
182 'EditPageTest_testCreatePage',
186 'wpTextbox1' =>
"Hello World!",
188 EditPage::AS_SUCCESS_NEW_ARTICLE,
190 "expected article being created"
191 )->doDeleteArticleReal(
'EditPageTest_testCreatePage' );
194 'EditPageTest_testCreatePage',
200 EditPage::AS_BLANK_ARTICLE,
202 "expected article not being created if empty"
210 'wpTextbox1' =>
"Not January",
212 EditPage::AS_SUCCESS_NEW_ARTICLE,
214 "expected MediaWiki: page being created"
215 )->doDeleteArticleReal(
'EditPageTest_testCreatePage' );
218 'MediaWiki:EditPageTest_testCreatePage',
224 EditPage::AS_BLANK_ARTICLE,
226 "expected not-registered MediaWiki: page not being created if empty"
236 EditPage::AS_SUCCESS_NEW_ARTICLE,
238 "expected registered MediaWiki: page being created even if empty"
239 )->doDeleteArticleReal(
'EditPageTest_testCreatePage' );
242 'MediaWiki:Ipb-default-expiry',
248 EditPage::AS_BLANK_ARTICLE,
250 "expected registered MediaWiki: page whose default content is empty not being created if empty"
258 'wpTextbox1' =>
"January",
260 EditPage::AS_BLANK_ARTICLE,
262 "expected MediaWiki: page not being created if text equals default message"
269 'wpTextbox1' => $text,
270 'wpSummary' =>
'first update',
273 $page = $this->
assertEdit(
'EditPageTest_testUpdatePage',
"zero",
null, $edit,
274 EditPage::AS_SUCCESS_UPDATE, $text,
275 "expected successfull update with given text" );
281 'wpTextbox1' => $text,
282 'wpSummary' =>
'second update',
285 $this->
assertEdit(
'EditPageTest_testUpdatePage',
null,
null, $edit,
286 EditPage::AS_SUCCESS_UPDATE, $text,
287 "expected successfull update with given text" );
300 $sectionOne =
'== one ==
304 $newSection =
'== new section ==
309 $textWithNewSectionOne = preg_replace(
310 '/== one ==.*== two ==/ms',
311 "$sectionOne\n== two ==", $text
314 $textWithNewSectionAdded =
"$text\n$newSection";
329 'replace first section',
330 $textWithNewSectionOne,
338 $textWithNewSectionAdded,
349 'wpTextbox1' => $text,
354 $this->
assertEdit(
'EditPageTest_testSectionEdit', $base,
null, $edit,
355 EditPage::AS_SUCCESS_UPDATE, $expected,
356 "expected successfull update of section" );
362 $tests[] =
array( #0: plain conflict
363 "Elmo", # base edit
user
364 "one\n\ntwo\n\nthree\n",
367 'wpTextbox1
' => "ONE\n\ntwo\n\nthree\n",
371 'wpTextbox1' =>
"(one)\n\ntwo\n\nthree\n",
373 EditPage::AS_CONFLICT_DETECTED, # expected
code
374 "ONE\n\ntwo\n\nthree\n", # expected
text
375 'expected edit conflict', #
message
378 $tests[] =
array( #1: successful merge
379 "Elmo", # base edit
user
380 "one\n\ntwo\n\nthree\n",
383 'wpTextbox1
' => "ONE\n\ntwo\n\nthree\n",
387 'wpTextbox1' =>
"one\n\ntwo\n\nTHREE\n",
389 EditPage::AS_SUCCESS_UPDATE, # expected
code
390 "ONE\n\ntwo\n\nTHREE\n", # expected
text
391 'expected automatic merge', #
message
395 $text .=
"== first section ==\n\n";
396 $text .=
"one\n\ntwo\n\nthree\n\n";
397 $text .=
"== second section ==\n\n";
398 $text .=
"four\n\nfive\n\nsix\n\n";
401 $section = preg_replace(
'/.*(== first section ==.*)== second section ==.*/sm',
'$1', $text );
404 $expected = str_replace(
'one',
'ONE', str_replace(
'three',
'THREE', $text ) );
407 "Elmo", # base edit
user
411 'wpTextbox1
' => str_replace( 'one
', 'ONE
', $section ),
416 'wpTextbox1' => str_replace(
'three',
'THREE',
$section ),
419 EditPage::AS_SUCCESS_UPDATE, # expected
code
420 $expected, # expected
text
421 'expected automatic section merge', #
message
425 $testsWithAdam = array_map(
function (
$test ) {
430 $testsWithBerta = array_map(
function (
$test ) {
435 return array_merge( $tests, $testsWithAdam, $testsWithBerta );
443 $expectedCode, $expectedText, $message =
null
452 if ( $page->exists() ) {
453 $page->doDeleteArticle(
"clean slate for testing" );
457 'wpTextbox1' => $text,
460 $page = $this->
assertEdit(
'EditPageTest_testAutoMerge',
null,
461 $baseUser, $baseEdit,
null,
null, __METHOD__ );
465 $edittime = $page->getTimestamp();
468 if ( !isset( $adamsEdit[
'wpStarttime'] ) ) {
469 $adamsEdit[
'wpStarttime'] = 1;
472 if ( !isset( $bertasEdit[
'wpStarttime'] ) ) {
473 $bertasEdit[
'wpStarttime'] = 2;
480 $adamsEdit[
'wpStarttime'] = $adamsTime;
481 $bertasEdit[
'wpStarttime'] = $bertasTime;
483 $adamsEdit[
'wpSummary'] =
'Adam\'s edit';
484 $bertasEdit[
'wpSummary'] =
'Bertas\'s edit';
486 $adamsEdit[
'wpEdittime'] = $edittime;
487 $bertasEdit[
'wpEdittime'] = $edittime;
490 $this->
assertEdit(
'EditPageTest_testAutoMerge',
null,
'Adam', $adamsEdit,
491 EditPage::AS_SUCCESS_UPDATE,
null,
"expected successfull update" );
494 $this->
assertEdit(
'EditPageTest_testAutoMerge',
null,
'Berta', $bertasEdit,
495 $expectedCode, $expectedText, $message );
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
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.
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
static provideAutoMerge()
testExtractSectionTitle( $section, $title)
@dataProvider provideExtractSectionTitle @covers EditPage::extractSectionTitle
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Class representing a MediaWiki article and history.
static provideExtractSectionTitle()
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static provideSectionEdit()
forceRevisionDate(WikiPage $page, $timestamp)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
getLatest()
Get the page_latest field.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
presenting them properly to the user as errors is done by the caller $title
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit, $expectedCode, $expectedText, $message=null)
@dataProvider provideAutoMerge @covers EditPage
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
assertEdit( $title, $baseText, $user=null, array $edit, $expectedCode=EditPage::AS_OK, $expectedText=null, $message=null)
Performs an edit and checks the result.
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
Class for viewing MediaWiki article and history.
assertEditedTextEquals( $expected, $actual, $msg='')
User input text is passed to rtrim() by edit page.
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
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 after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
testSectionEdit( $base, $section, $text, $summary, $expected)
@dataProvider provideSectionEdit @covers EditPage