MediaWiki REL1_28
Go to the documentation of this file.
15 protected $context;
17 private static $revisions;
19 protected function setUp() {
20 parent::setUp();
22 $title = $this->getTitle();
24 $this->context = new RequestContext();
25 $this->context->setTitle( $title );
27 if ( !self::$revisions ) {
28 self::$revisions = $this->doEdits();
29 }
30 }
35 protected function getTitle() {
36 $namespace = $this->getDefaultWikitextNS();
37 return Title::newFromText( 'Kitten', $namespace );
38 }
43 protected function doEdits() {
44 $title = $this->getTitle();
47 $strings = [ "it is a kitten", "two kittens", "three kittens", "four kittens" ];
48 $revisions = [];
50 foreach ( $strings as $string ) {
52 $page->doEditContent( $content, 'edit page' );
53 $revisions[] = $page->getLatest();
54 }
56 return $revisions;
57 }
59 public function testMapDiffPrevNext() {
60 $cases = $this->getMapDiffPrevNextCases();
62 foreach ( $cases as $case ) {
63 list( $expected, $old, $new, $message ) = $case;
65 $diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
66 $diffMap = $diffEngine->mapDiffPrevNext( $old, $new );
67 $this->assertEquals( $expected, $diffMap, $message );
68 }
69 }
71 private function getMapDiffPrevNextCases() {
72 $revs = self::$revisions;
74 return [
75 [ [ $revs[1], $revs[2] ], $revs[2], 'prev', 'diff=prev' ],
76 [ [ $revs[2], $revs[3] ], $revs[2], 'next', 'diff=next' ],
77 [ [ $revs[1], $revs[3] ], $revs[1], $revs[3], 'diff=' . $revs[3] ]
78 ];
79 }
81 public function testLoadRevisionData() {
82 $cases = $this->getLoadRevisionDataCases();
84 foreach ( $cases as $case ) {
85 list( $expectedOld, $expectedNew, $old, $new, $message ) = $case;
87 $diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
88 $diffEngine->loadRevisionData();
90 $this->assertEquals( $diffEngine->getOldid(), $expectedOld, $message );
91 $this->assertEquals( $diffEngine->getNewid(), $expectedNew, $message );
92 }
93 }
95 private function getLoadRevisionDataCases() {
96 $revs = self::$revisions;
98 return [
99 [ $revs[2], $revs[3], $revs[3], 'prev', 'diff=prev' ],
100 [ $revs[2], $revs[3], $revs[2], 'next', 'diff=next' ],
101 [ $revs[1], $revs[3], $revs[1], $revs[3], 'diff=' . $revs[3] ],
102 [ $revs[1], $revs[3], $revs[1], 0, 'diff=0' ]
103 ];
104 }
106 public function testGetOldid() {
107 $revs = self::$revisions;
109 $diffEngine = new DifferenceEngine( $this->context, $revs[1], $revs[2], 2, true, false );
110 $this->assertEquals( $revs[1], $diffEngine->getOldid(), 'diff get old id' );
111 }
113 public function testGetNewid() {
114 $revs = self::$revisions;
116 $diffEngine = new DifferenceEngine( $this->context, $revs[1], $revs[2], 2, true, false );
117 $this->assertEquals( $revs[2], $diffEngine->getNewid(), 'diff get new id' );
118 }
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Returns the ID of a namespace that defaults to Wikitext.
Group all the pieces relevant to the context of a request into one instance.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition WikiPage.php:115
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
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
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:986
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition hooks.txt:1094
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition hooks.txt:2534
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
Definition injection.txt:37