Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4111804
SiteStatsTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SiteStatsTest.php
View Options
<?php
use
MediaWiki\SiteStats\SiteStats
;
use
Wikimedia\ObjectCache\HashBagOStuff
;
use
Wikimedia\ObjectCache\WANObjectCache
;
use
Wikimedia\Rdbms\Platform\ISQLPlatform
;
/**
* @group Database
*/
class
SiteStatsTest
extends
MediaWikiIntegrationTestCase
{
/**
* @covers \MediaWiki\SiteStats\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 \MediaWiki\SiteStats\SiteStats
*/
public
function
testInit
()
{
$this
->
getDb
()->
newDeleteQueryBuilder
()
->
deleteFrom
(
'site_stats'
)
->
where
(
ISQLPlatform
::
ALL_ROWS
)
->
caller
(
__METHOD__
)
->
execute
();
SiteStats
::
unload
();
SiteStats
::
edits
();
$row
=
$this
->
getDb
()->
newSelectQueryBuilder
()
->
select
(
'1'
)
->
from
(
'site_stats'
)
->
caller
(
__METHOD__
)->
fetchRow
();
$this
->
assertNotFalse
(
$row
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 22:33 (22 h, 39 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
85/17/428f345c7b7c070ea09ea040d194
Default Alt Text
SiteStatsTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment