MediaWiki REL1_31
SiteStatsTest.php
Go to the documentation of this file.
1<?php
2
4
9 $this->setService( 'MainWANObjectCache',
10 new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ) );
11 $cache = \MediaWiki\MediaWikiServices::getInstance()->getMainWANObjectCache();
13
14 // Delete jobs that might have been left behind by other tests
15 $jobq->get( 'htmlCacheUpdate' )->delete();
16 $jobq->get( 'recentChangesUpdate' )->delete();
17 $jobq->get( 'userGroupExpiry' )->delete();
18 $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
19
20 $jobq->push( new NullJob( Title::newMainPage(), [] ) );
21 $this->assertEquals( 1, SiteStats::jobs(),
22 'A single job enqueued bumps jobscount stat to 1' );
23
24 $jobq->push( new NullJob( Title::newMainPage(), [] ) );
25 $this->assertEquals( 1, SiteStats::jobs(),
26 'SiteStats::jobs() count does not reflect addition ' .
27 'of a second job (cached)'
28 );
29
30 $jobq->get( 'null' )->delete(); // clear jobqueue
31 $this->assertEquals( 0, $jobq->get( 'null' )->getSize(),
32 'Job queue for NullJob has been cleaned' );
33
34 $cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
35 $this->assertEquals( 1, SiteStats::jobs(),
36 'jobs count is kept in process cache' );
37
38 $cache->clearProcessCache();
39 $this->assertEquals( 0, SiteStats::jobs() );
40 }
41
42}
Simple store for keeping values in an associative array for the current process.
static singleton( $domain=false)
setService( $name, $object)
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown.
Degenerate job that does nothing, but can optionally replace itself in the queue and/or sleep for a b...
Definition NullJob.php:47
testJobsCountGetCached()
SiteStats::jobs.
static jobs()
Total number of jobs in the job queue.
Multi-datacenter aware caching interface.
$cache
Definition mcc.php:33