wiki.techinc.nl/tests/phpunit/includes/SiteStatsTest.php
Func 4d1da6f7f8 phpunit: Update @covers annotations for namespaced classes
We renamed many classes to be namespaced, but the `@covers` and
`@coversDefaultClass` annotations weren't updated properly.

PHPUnit didn't support short cover annotations with `use` statements,
these didn't trigger any errors yet, because they are class alias.

This patch is populated by a modified version of PhpunitAnnotationsSniff.

Change-Id: I6c602290a30099239b17d2dc0d67b1488b4eaeeb
2023-05-27 17:43:12 +08:00

50 lines
1.4 KiB
PHP

<?php
use MediaWiki\SiteStats\SiteStats;
/**
* @group Database
*/
class SiteStatsTest extends MediaWikiIntegrationTestCase {
/**
* @covers MediaWiki\SiteStats\SiteStats::jobs
*/
public function testJobsCountGetCached() {
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$this->setService( 'MainWANObjectCache', $cache );
$jobq = $this->getServiceContainer()->getJobQueueGroup();
$jobq->push( new NullJob( [] ) );
$this->assertSame( 1, SiteStats::jobs(),
'A single job enqueued bumps jobscount stat to 1' );
$jobq->push( new NullJob( [] ) );
$this->assertSame( 1, SiteStats::jobs(),
'SiteStats::jobs() count does not reflect addition ' .
'of a second job (cached)'
);
$jobq->get( 'null' )->delete(); // clear jobqueue
$this->assertSame( 0, $jobq->get( 'null' )->getSize(),
'Job queue for NullJob has been cleaned' );
$cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
$this->assertSame( 1, SiteStats::jobs(),
'jobs count is kept in process cache' );
$cache->clearProcessCache();
$this->assertSame( 0, SiteStats::jobs() );
}
/**
* @covers MediaWiki\SiteStats\SiteStats
*/
public function testInit() {
$this->db->delete( 'site_stats', IDatabase::ALL_ROWS, __METHOD__ );
SiteStats::unload();
SiteStats::edits();
$this->assertNotFalse( $this->db->selectRow( 'site_stats', '1', IDatabase::ALL_ROWS, __METHOD__ ) );
}
}