30 $this->context->setTitle( $title );
32 if ( !self::$revisions ) {
33 self::$revisions = $this->
doEdits();
42 return Title::newFromText(
'Kitten', $namespace );
50 $page = WikiPage::factory( $title );
52 $strings = [
"it is a kitten",
"two kittens",
"three kittens",
"four kittens" ];
55 foreach ( $strings as $string ) {
56 $content = ContentHandler::makeContent( $string, $title );
57 $page->doEditContent(
$content,
'edit page' );
67 foreach ( $cases as $case ) {
68 list( $expected, $old, $new, $message ) =
$case;
70 $diffEngine =
new DifferenceEngine( $this->context, $old, $new, 2,
true,
false );
71 $diffMap = $diffEngine->mapDiffPrevNext( $old, $new );
80 [ [ $revs[1], $revs[2] ], $revs[2],
'prev',
'diff=prev' ],
81 [ [ $revs[2], $revs[3] ], $revs[2],
'next',
'diff=next' ],
82 [ [ $revs[1], $revs[3] ], $revs[1], $revs[3],
'diff=' . $revs[3] ]
89 foreach ( $cases as $testName => $case ) {
90 list( $expectedOld, $expectedNew, $expectedRet, $old, $new ) =
$case;
92 $diffEngine =
new DifferenceEngine( $this->context, $old, $new, 2,
true,
false );
93 $ret = $diffEngine->loadRevisionData();
94 $ret2 = $diffEngine->loadRevisionData();
96 $this->
assertEquals( $expectedOld, $diffEngine->getOldid(), $testName );
97 $this->
assertEquals( $expectedNew, $diffEngine->getNewid(), $testName );
107 'diff=prev' => [ $revs[2], $revs[3],
true, $revs[3],
'prev' ],
108 'diff=next' => [ $revs[2], $revs[3],
true, $revs[2],
'next' ],
109 'diff=' . $revs[3] => [ $revs[1], $revs[3],
true, $revs[1], $revs[3] ],
110 'diff=0' => [ $revs[1], $revs[3],
true, $revs[1], 0 ],
111 'diff=prev&oldid=<first>' => [
false, $revs[0],
true, $revs[0],
'prev' ],
112 'invalid' => [ 123456789, $revs[1],
false, 123456789, $revs[1] ],
119 $diffEngine =
new DifferenceEngine( $this->context, $revs[1], $revs[2], 2,
true,
false );
120 $this->
assertEquals( $revs[1], $diffEngine->getOldid(),
'diff get old id' );
126 $diffEngine =
new DifferenceEngine( $this->context, $revs[1], $revs[2], 2,
true,
false );
127 $this->
assertEquals( $revs[2], $diffEngine->getNewid(),
'diff get new id' );
132 'moved paragraph left shoud get new location title' => [
133 '<a class="mw-diff-movedpara-left">⚫</a>',
134 '<a class="mw-diff-movedpara-left" title="(diff-paragraph-moved-tonew)">⚫</a>',
136 'moved paragraph right shoud get old location title' => [
137 '<a class="mw-diff-movedpara-right">⚫</a>',
138 '<a class="mw-diff-movedpara-right" title="(diff-paragraph-moved-toold)">⚫</a>',
140 'nothing changed when key not hit' => [
141 '<a class="mw-diff-movedpara-rightis">⚫</a>',
142 '<a class="mw-diff-movedpara-rightis">⚫</a>',
152 $diffEngine = TestingAccessWrapper::newFromObject(
new DifferenceEngine() );
165 'wgExternalDiffEngine' =>
'/dev/null',
175 'testing-nontext' => DummyNonTextContentHandler::class,
190 'wgExternalDiffEngine' =>
'/dev/null',
193 $oldText =
"aaa\nbbb\nccc";
194 $newText =
"aaa\nxxx\nccc";
195 $expectedDiff =
" aaa aaa\n-bbb+xxx\n ccc ccc";
206 'wgExternalDiffEngine' =>
'/dev/null',
219 $main1 = SlotRecord::newUnsaved( SlotRecord::MAIN,
221 $main2 = SlotRecord::newUnsaved( SlotRecord::MAIN,
246 'wgExternalDiffEngine' =>
'/dev/null',
249 if ( $expectedDiff instanceof Exception ) {
254 if ( $expectedDiff instanceof Exception ) {
263 $main1 = SlotRecord::newUnsaved( SlotRecord::MAIN,
265 $main2 = SlotRecord::newUnsaved( SlotRecord::MAIN,
267 $slot1 = SlotRecord::newUnsaved(
'slot',
269 $slot2 = SlotRecord::newUnsaved(
'slot',
273 'revision vs. null' => [
278 'revision vs. itself' => [
283 'different text in one slot' => [
286 "slotLine 1:\nLine 1:\n-aaa+bbb",
288 'different text in two slots' => [
291 "Line 1:\nLine 1:\n-xxx+yyy\nslotLine 1:\nLine 1:\n-aaa+bbb",
296 "slotLine 1:\nLine 1:\n- +aaa",
306 $customDifferenceEngine = $this->
getMockBuilder( DifferenceEngine::class )
307 ->enableProxyingToOriginalMethods()
309 $customContentHandler = $this->
getMockBuilder( ContentHandler::class )
310 ->setConstructorArgs( [
'foo', [] ] )
311 ->setMethods( [
'createDifferenceEngine' ] )
312 ->getMockForAbstractClass();
313 $customContentHandler->expects( $this->
any() )
314 ->method(
'createDifferenceEngine' )
315 ->willReturn( $customDifferenceEngine );
318 ->setMethods( [
'getContentHandler' ] )
319 ->getMockForAbstractClass();
320 $customContent->expects( $this->
any() )
321 ->method(
'getContentHandler' )
322 ->willReturn( $customContentHandler );
326 $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
328 ': could not maintain backwards compatibility. Please use a SlotDiffRenderer.' );
329 $slotDiffRenderer->getDiff( $customContent, $customContent2 );
352 ->disableOriginalConstructor()
354 $mock->expects( $this->
any() )
355 ->method(
'getDBkey' )
357 $mock->expects( $this->
any() )
358 ->method(
'getArticleID' )
371 foreach ( $slots as $slot ) {
372 $revision->setSlot( $slot );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
getPlainDiff( $diff)
Convert a HTML diff to a human-readable format and hopefully make the test less fragile.
testAddLocalisedTitleTooltips( $input, $expected)
provideLocaliseTitleTooltipsTestData
provideGenerateContentDiffBody()
getLoadRevisionDataCases()
getMapDiffPrevNextCases()
getRevisionRecord(... $slots)
testGetDiffBody(RevisionRecord $oldRevision=null, RevisionRecord $newRevision=null, $expectedDiff)
provideGetDiffBody
testGenerateTextDiffBody()
provideLocaliseTitleTooltipsTestData()
testGenerateContentDiffBody(Content $oldContent, Content $newContent, $expectedDiff)
provideGenerateContentDiffBody
DifferenceEngine is responsible for rendering the difference between two revisions as HTML.
Group all the pieces relevant to the context of a request into one instance.
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
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify as strings Extensions should add to this list prev or next refreshes the diff cache allow viewing deleted revs & $differenceEngine
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 & $ret
Base interface for content objects.
if(is_array($mode)) switch( $mode) $input