rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / SiteStatsTest.php
blobea476a7cfa01e832a1108832982b3683edb43e7c
1 <?php
3 class SiteStatsTest extends MediaWikiTestCase {
5 /**
6 * @covers SiteStats::jobs
7 */
8 function testJobsCountGetCached() {
9 $this->setService( 'MainWANObjectCache',
10 new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ) );
11 $cache = \MediaWiki\MediaWikiServices::getInstance()->getMainWANObjectCache();
12 $jobq = JobQueueGroup::singleton();
14 $jobq->push( new NullJob( Title::newMainPage(), [] ) );
15 $this->assertEquals( 1, SiteStats::jobs(),
16 'A single job enqueued bumps jobscount stat to 1' );
18 $jobq->push( new NullJob( Title::newMainPage(), [] ) );
19 $this->assertEquals( 1, SiteStats::jobs(),
20 'SiteStats::jobs() count does not reflect addition ' .
21 'of a second job (cached)'
24 $jobq->get( 'null' )->delete(); // clear jobqueue
25 $this->assertEquals( 0, $jobq->get( 'null' )->getSize(),
26 'Job queue for NullJob has been cleaned' );
28 $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
29 $this->assertEquals( 1, SiteStats::jobs(),
30 'jobs count is kept in process cache' );
32 $cache->clearProcessCache();
33 $this->assertEquals( 0, SiteStats::jobs() );