deferred: Widen @covers annotations in unit tests

Follows-up I98d2ecc987, I7555c9b6b5, I6d845bdfbb, I69b5385868, I4c7d826c7e,
I1287f3979a, which widened the `@covers` annotations of other suites:

> We lose useful coverage and spend valuable time keeping these tags
> accurate through refactors (or worse, forget to do so).
>
> I've audited each test to confirm it is a general test of the
> subject class, where adding any called methods would be an accepted
> change, thus widening it is merely a no-op that clarifies intent
> and reduces maintenance. I am not disabling the "only track coverage
> of specified subject" benefits, nor am I claiming coverage in
> in classes outside the subject under test.
>
> Tracking tiny details per-method wastes time in keeping references
> in sync during refactors, time to realize (and fix) when people
> inevitably don't keep them in sync, time lost in finding uncovered
> code to write tests for only to realize it was already covered but
> not yet claimed, etc.

Change-Id: I133c7b707aab7ceb4f2ecd3be38bd4bd1b194143
This commit is contained in:
Timo Tijhof 2023-08-22 00:01:58 +01:00
parent ae8c71feae
commit 87846c95a6
5 changed files with 24 additions and 89 deletions

View file

@ -3,11 +3,11 @@
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Title\Title;
/**
* @covers CdnCacheUpdate
*/
class CdnCacheUpdateTest extends MediaWikiIntegrationTestCase {
/**
* @covers CdnCacheUpdate::merge
*/
public function testPurgeMergeWeb() {
$this->setMwGlobals( 'wgCommandLineMode', false );
$this->setService( 'LinkBatchFactory', $this->createMock( LinkBatchFactory::class ) );

View file

@ -2,16 +2,12 @@
/**
* @group Database
* @covers DeferredUpdates
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
/**
* @covers DeferredUpdates::addUpdate
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdates::attemptUpdate
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testAddAndRun() {
$update = $this->getMockBuilder( DeferrableUpdate::class )
->onlyMethods( [ 'doUpdate' ] )->getMock();
@ -21,11 +17,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
DeferredUpdates::doUpdates();
}
/**
* @covers DeferredUpdates::addUpdate
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testAddMergeable() {
$this->setMwGlobals( 'wgCommandLineMode', false );
@ -43,10 +34,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
DeferredUpdates::addUpdate( $update2 );
}
/**
* @covers DeferredUpdates::addCallableUpdate
* @covers MWCallableUpdate::getOrigin
*/
public function testAddCallableUpdate() {
$this->setMwGlobals( 'wgCommandLineMode', true );
@ -59,10 +46,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertSame( 1, $ran, 'Update ran' );
}
/**
* @covers DeferredUpdates::getPendingUpdates
* @covers DeferredUpdates::clearPendingUpdates
*/
public function testGetPendingUpdates() {
// Prevent updates from running
$this->setMwGlobals( 'wgCommandLineMode', false );
@ -92,12 +75,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertSame( [], DeferredUpdates::getPendingUpdates() );
}
/**
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdates::addUpdate
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testDoUpdatesWeb() {
$this->setMwGlobals( 'wgCommandLineMode', false );
@ -190,12 +167,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertEquals( "Marychu", $y, "POSTSEND update ran" );
}
/**
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdates::addUpdate
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testDoUpdatesCLI() {
$this->setMwGlobals( 'wgCommandLineMode', true );
$updates = [
@ -265,12 +236,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
DeferredUpdates::doUpdates();
}
/**
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdates::addUpdate
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testPresendAddOnPostsendRun() {
$this->setMwGlobals( 'wgCommandLineMode', true );
@ -299,9 +264,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertTrue( $y, "Nested PRESEND update ran" );
}
/**
* @covers DeferredUpdates::attemptUpdate
*/
public function testRunUpdateTransactionScope() {
$this->setMwGlobals( 'wgCommandLineMode', false );
@ -320,8 +282,7 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
}
/**
* @covers DeferredUpdates::attemptUpdate
* @covers TransactionRoundDefiningUpdate::getOrigin
* @covers TransactionRoundDefiningUpdate
*/
public function testRunOuterScopeUpdate() {
$this->setMwGlobals( 'wgCommandLineMode', false );
@ -341,12 +302,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertSame( 1, $ran, 'Update ran' );
}
/**
* @covers DeferredUpdates::tryOpportunisticExecute
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testTryOpportunisticExecute() {
$calls = [];
$callback1 = static function () use ( &$calls ) {
@ -382,9 +337,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertEquals( [ 'oti', 1, 2 ], $calls );
}
/**
* @covers DeferredUpdates::attemptUpdate
*/
public function testCallbackUpdateRounds() {
$lbFactory = $this->getServiceContainer()->getDBLoadBalancerFactory();
@ -405,11 +357,6 @@ class DeferredUpdatesTest extends MediaWikiIntegrationTestCase {
$this->assertTrue( $called, "Callback ran" );
}
/**
* @covers DeferredUpdates::doUpdates
* @covers DeferredUpdatesScopeStack
* @covers DeferredUpdatesScope
*/
public function testNestedExecution() {
// No immediate execution
$this->setMwGlobals( 'wgCommandLineMode', false );

View file

@ -12,22 +12,21 @@ use Wikimedia\TestingAccessWrapper;
/**
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate
* @covers \MediaWiki\Deferred\LinksUpdate\CategoryLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\ExternalLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\ImageLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\LangLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\LinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\LinksTableGroup
* @covers \MediaWiki\Deferred\LinksUpdate\PageLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\PagePropsTable
* @covers \MediaWiki\Deferred\LinksUpdate\TemplateLinksTable
* @covers \MediaWiki\Deferred\LinksUpdate\TitleLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\CategoryLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\ExternalLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\GenericPageLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\ImageLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\InterwikiLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\LangLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\LinksTable
* @covers MediaWiki\Deferred\LinksUpdate\LinksTableGroup
* @covers MediaWiki\Deferred\LinksUpdate\PageLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\PagePropsTable
* @covers MediaWiki\Deferred\LinksUpdate\TemplateLinksTable
* @covers MediaWiki\Deferred\LinksUpdate\TitleLinksTable
*
* @group LinksUpdate
* @group Database
* ^--- make sure temporary tables are used.
*/
class LinksUpdateTest extends MediaWikiLangTestCase {
protected static $testingPageId;
@ -184,8 +183,6 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
/**
* @covers ParserOutput::addExternalLink
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate::getAddedExternalLinks
* @covers MediaWiki\Deferred\LinksUpdate\LinksUpdate::getRemovedExternalLinks
*/
public function testUpdate_externallinks() {
/** @var ParserOutput $po */

View file

@ -4,6 +4,7 @@ use MediaWiki\Page\PageIdentityValue;
/**
* @group Search
* @covers SearchUpdate
*/
class SearchUpdateTest extends MediaWikiIntegrationTestCase {
@ -22,9 +23,6 @@ class SearchUpdateTest extends MediaWikiIntegrationTestCase {
return trim( $this->su->updateText( $text ) );
}
/**
* @covers SearchUpdate::updateText
*/
public function testUpdateText() {
$this->assertEquals(
'test',
@ -58,9 +56,7 @@ EOT
}
/**
* @covers SearchUpdate::updateText
* Test T34712
* Test if unicode quotes in article links make its search index empty
* T34712: Test if unicode quotes in article links make its search index empty
*/
public function testUnicodeLinkSearchIndexError() {
$text = "text „http://example.com“ text";

View file

@ -6,12 +6,11 @@ use Wikimedia\TestingAccessWrapper;
/**
* @group Database
* @covers SiteStatsUpdate
* @covers MediaWiki\SiteStats\SiteStats
* @covers MediaWiki\SiteStats\SiteStatsInit
*/
class SiteStatsUpdateTest extends MediaWikiIntegrationTestCase {
/**
* @covers SiteStatsUpdate::factory
* @covers SiteStatsUpdate::merge
*/
public function testFactoryAndMerge() {
$update1 = SiteStatsUpdate::factory( [ 'pages' => 1, 'users' => 2 ] );
$update2 = SiteStatsUpdate::factory( [ 'users' => 1, 'images' => 1 ] );
@ -26,10 +25,6 @@ class SiteStatsUpdateTest extends MediaWikiIntegrationTestCase {
$this->assertSame( 0, $wrapped->articles );
}
/**
* @covers SiteStatsUpdate::doUpdate()
* @covers MediaWiki\SiteStats\SiteStatsInit::refresh()
*/
public function testDoUpdate() {
$dbw = wfGetDB( DB_PRIMARY );
$statsInit = new SiteStatsInit( $dbw );