3 class SiteStatsTest
extends MediaWikiTestCase
{
6 * @covers SiteStats::jobs
8 function testJobsCountGetCached() {
9 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
10 $this->setService( 'MainWANObjectCache', $cache );
11 $jobq = JobQueueGroup
::singleton();
13 $jobq->push( new NullJob( Title
::newMainPage(), [] ) );
14 $this->assertEquals( 1, SiteStats
::jobs(),
15 'A single job enqueued bumps jobscount stat to 1' );
17 $jobq->push( new NullJob( Title
::newMainPage(), [] ) );
18 $this->assertEquals( 1, SiteStats
::jobs(),
19 'SiteStats::jobs() count does not reflect addition ' .
20 'of a second job (cached)'
23 $jobq->get( 'null' )->delete(); // clear jobqueue
24 $this->assertEquals( 0, $jobq->get( 'null' )->getSize(),
25 'Job queue for NullJob has been cleaned' );
27 $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
28 $this->assertEquals( 1, SiteStats
::jobs(),
29 'jobs count is kept in process cache' );
31 $cache->clearProcessCache();
32 $this->assertEquals( 0, SiteStats
::jobs() );