mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-18 02:51:26 +00:00
8e44b43df0
Goal: ----- Finishing the work from Iadb7757debe000025e52770ca51ebcf24ca8ee66 by changing CommentParser::parse() to return a data object, instead of the whole parser. Changes: -------- ThreadItemSet.php: ThreadItemSet.js: * New data class to access the results of parsing a discussion. Most methods and properties are moved from CommentParser with no changes. CommentParser.php: Parser.js: * parse() returns a new ThreadItemSet. * Remove methods moved to ThreadItemSet. * Placeholder headings are generated slightly differently, as we process things in a different order. * Grouping threads and computing IDs/names is no longer lazy. We always needed IDs/names anyway. * computeId() explicitly uses a ThreadItemSet to check the existing IDs when de-duplicating. controller.js: * Move the code for turning some nodes annotated by CommentFormatter into a ThreadItemSet (previously a Parser) from controller#init to ThreadItemSet.static.newFromAnnotatedNodes, and rewrite it to handle assigning parents/replies and recalculating legacy IDs more nicely. * mw.dt.pageThreads is now a ThreadItemSet. Change-Id: I49bfe019aa460651447fd383f73eafa9d7180a92
65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
|
|
|
use MediaWiki\Extension\DiscussionTools\Notifications\EventDispatcher;
|
|
use MediaWiki\Extension\DiscussionTools\ThreadItemSet;
|
|
use MediaWiki\Page\PageIdentity;
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
use MediaWiki\User\UserIdentity;
|
|
use Title;
|
|
|
|
class MockEventDispatcher extends EventDispatcher {
|
|
|
|
/**
|
|
* Public for testing
|
|
*
|
|
* Note that we can't use TestingAccessWrapper instead of this, because it doesn't support passing
|
|
* arguments by reference (causes exceptions like "PHPUnit\Framework\Error\Warning: Parameter 1 to
|
|
* ... expected to be a reference, value given").
|
|
*
|
|
* @param array &$events
|
|
* @param ThreadItemSet $oldItemSet
|
|
* @param ThreadItemSet $newItemSet
|
|
* @param RevisionRecord $newRevRecord
|
|
* @param PageIdentity $title
|
|
* @param UserIdentity $user
|
|
*/
|
|
public static function generateEventsFromItemSets(
|
|
array &$events,
|
|
ThreadItemSet $oldItemSet,
|
|
ThreadItemSet $newItemSet,
|
|
RevisionRecord $newRevRecord,
|
|
PageIdentity $title,
|
|
UserIdentity $user
|
|
): void {
|
|
parent::generateEventsFromItemSets(
|
|
$events,
|
|
$oldItemSet,
|
|
$newItemSet,
|
|
$newRevRecord,
|
|
$title,
|
|
$user
|
|
);
|
|
}
|
|
|
|
/**
|
|
* No-op for testing
|
|
*
|
|
* @param RevisionRecord $newRevRecord
|
|
*/
|
|
public static function addCommentChangeTag( RevisionRecord $newRevRecord ): void {
|
|
}
|
|
|
|
/**
|
|
* No-op for testing
|
|
*
|
|
* @param UserIdentity $user
|
|
* @param Title $title
|
|
* @param string $itemName
|
|
*/
|
|
protected static function addAutoSubscription( UserIdentity $user, Title $title, string $itemName ): void {
|
|
}
|
|
|
|
}
|