wiki.techinc.nl/tests/phpunit/includes/SiteStatsTest.php
addshore 959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00

35 lines
1 KiB
PHP

<?php
class SiteStatsTest extends MediaWikiIntegrationTestCase {
/**
* @covers SiteStats::jobs
*/
public function testJobsCountGetCached() {
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$this->setService( 'MainWANObjectCache', $cache );
$jobq = JobQueueGroup::singleton();
$jobq->push( Job::factory( 'null', Title::newMainPage(), [] ) );
$this->assertSame( 1, SiteStats::jobs(),
'A single job enqueued bumps jobscount stat to 1' );
$jobq->push( Job::factory( 'null', Title::newMainPage(), [] ) );
$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() );
}
}