Avoid DB access in non-database tests

Use mocks in CommentFormatterTest to avoid DB access, because the test
doesn't need it.

Add EventDispatcherTest to the Database group because it uses Parser,
whose DB access is hard to prevent.

Change-Id: Idfbf6c83a454f359e491e8c61e0629aad643d54f
This commit is contained in:
Daimona Eaytoy 2023-08-07 21:46:14 +02:00
parent 0ef532149b
commit ec41af6e8b
2 changed files with 8 additions and 4 deletions

View file

@ -3,8 +3,10 @@
namespace MediaWiki\Extension\DiscussionTools\Tests;
use FormatJson;
use GenderCache;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\UserIdentity;
use ParserOutput;
use Title;
use Wikimedia\TestingAccessWrapper;
@ -19,8 +21,9 @@ class CommentFormatterTest extends IntegrationTestCase {
* @dataProvider provideAddDiscussionToolsInternal
*/
public function testAddDiscussionToolsInternal(
string $name, string $title, string $dom, string $expected, string $config, string $data, bool $isMobile
string $name, string $titleText, string $dom, string $expected, string $config, string $data, bool $isMobile
): void {
$this->setService( 'GenderCache', $this->createMock( GenderCache::class ) );
$dom = static::getHtml( $dom );
$expectedPath = $expected;
$expected = static::getText( $expectedPath );
@ -32,7 +35,7 @@ class CommentFormatterTest extends IntegrationTestCase {
MainConfigNames::ScriptPath => '/w',
MainConfigNames::Script => '/w/index.php',
] );
$title = Title::newFromText( $title );
$title = Title::newFromText( $titleText );
MockCommentFormatter::$parser = static::createParser( $data );
$commentFormatter = TestingAccessWrapper::newFromClass( MockCommentFormatter::class );
@ -59,11 +62,11 @@ class CommentFormatterTest extends IntegrationTestCase {
$actual = $preprocessed;
$actual = MockCommentFormatter::postprocessTopicSubscription(
$actual, $qqxLang, $title, $mockSubStore, static::getTestUser()->getUser(), $isMobile
$actual, $qqxLang, $title, $mockSubStore, $this->createMock( UserIdentity::class ), $isMobile
);
$actual = MockCommentFormatter::postprocessVisualEnhancements(
$actual, $qqxLang, static::getTestUser()->getUser(), $isMobile
$actual, $qqxLang, $this->createMock( UserIdentity::class ), $isMobile
);
$actual = MockCommentFormatter::postprocessReplyTool(

View file

@ -11,6 +11,7 @@ use MediaWiki\User\UserIdentityValue;
/**
* @group DiscussionTools
* @group Database
* @covers \MediaWiki\Extension\DiscussionTools\Notifications\EventDispatcher
*/
class EventDispatcherTest extends IntegrationTestCase {