Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2751389
UnreadWikisTest.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
UnreadWikisTest.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Test
;
use
MediaWiki\Extension\Notifications\DbFactory
;
use
MediaWiki\Extension\Notifications\UnreadWikis
;
use
MediaWiki\Utils\MWTimestamp
;
use
MediaWikiIntegrationTestCase
;
use
Wikimedia\TestingAccessWrapper
;
/**
* Tests for unread wiki database access
*
* @group Database
* @covers \MediaWiki\Extension\Notifications\UnreadWikis
*/
class
UnreadWikisTest
extends
MediaWikiIntegrationTestCase
{
public
function
testUpdateCount
()
{
$unread
=
TestingAccessWrapper
::
newFromObject
(
new
UnreadWikis
(
1
)
);
$unread
->
dbFactory
=
$this
->
mockDbFactory
(
$this
->
db
);
$unread
->
updateCount
(
'foobar'
,
2
,
new
MWTimestamp
(
'20220322222222'
),
3
,
new
MWTimestamp
(
'20220322222223'
)
);
$this
->
assertSame
(
[
'foobar'
=>
[
'alert'
=>
[
'count'
=>
'2'
,
'ts'
=>
'20220322222222'
],
'message'
=>
[
'count'
=>
'3'
,
'ts'
=>
'20220322222223'
],
]
],
$unread
->
getUnreadCounts
()
);
}
public
function
testUpdateCountFalse
()
{
$unread
=
TestingAccessWrapper
::
newFromObject
(
new
UnreadWikis
(
1
)
);
$unread
->
dbFactory
=
$this
->
mockDbFactory
(
$this
->
db
);
$unread
->
updateCount
(
'foobar'
,
3
,
false
,
4
,
false
);
$this
->
assertSame
(
[
'foobar'
=>
[
'alert'
=>
[
'count'
=>
'3'
,
'ts'
=>
'00000000000000'
],
'message'
=>
[
'count'
=>
'4'
,
'ts'
=>
'00000000000000'
],
]
],
$unread
->
getUnreadCounts
()
);
}
/**
* Mock object of DbFactory
* @param \Wikimedia\Rdbms\IDatabase $db
* @return DbFactory
*/
protected
function
mockDbFactory
(
$db
)
{
$dbFactory
=
$this
->
createMock
(
DbFactory
::
class
);
$dbFactory
->
expects
(
$this
->
any
()
)
->
method
(
'getSharedDb'
)
->
willReturn
(
$db
);
return
$dbFactory
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Jul 3, 18:27 (1 d, 13 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
39/1f/3670343d4a5e9a6ac06f30da3f41
Default Alt Text
UnreadWikisTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment