wiki.techinc.nl/tests/phpunit/includes/SiteStatsTest.php
Umherirrender 2b44fbe3eb SiteStats: Remove unneeded SiteStats::salvageIncorrectRow
The function SiteStats::salvageIncorrectRow is a noop,
the variable $map is not returned, instead the unmodified $row is
returned, function added in 6535091

self::doLoadFromDB on second attempt after the initialize (via
doPlaceholderInit or doAllAndCommit) returns a valid row, making this
extra check no longer needed (possible since 27c76fa).

Fix doLoadFromDB on first attempt for empty table, broken since 5156ae0

Change-Id: Iec2b4bbdb2ca546eb377a6d12106d62b5219886f
2023-02-13 21:23:40 +01:00

48 lines
1.3 KiB
PHP

<?php
/**
* @group Database
*/
class SiteStatsTest extends MediaWikiIntegrationTestCase {
/**
* @covers 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 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__ ) );
}
}