Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4077464
EmailNotificationTest.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
EmailNotificationTest.php
View Options
<?php
use
MediaWiki\MainConfigNames
;
use
MediaWiki\Title\Title
;
/**
* @group Database
* @group Mail
* @covers \EmailNotification
*/
class
EmailNotificationTest
extends
MediaWikiIntegrationTestCase
{
/** @var EmailNotification */
protected
$emailNotification
;
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
emailNotification
=
new
EmailNotification
();
$this
->
overrideConfigValue
(
MainConfigNames
::
WatchlistExpiry
,
true
);
}
public
function
testNotifyOnPageChange
():
void
{
$store
=
$this
->
getServiceContainer
()->
getWatchedItemStore
();
// both Alice and Bob watch 'Foobar'
$title
=
Title
::
makeTitle
(
NS_MAIN
,
'Foobar'
);
$alice
=
$this
->
getTestSysop
()->
getUser
();
$store
->
addWatch
(
$alice
,
$title
);
$bob
=
$this
->
getTestUser
()->
getUser
();
$store
->
addWatch
(
$bob
,
$title
);
// Alice edits the page (doesn't actually have to edit in this test).
// Bob (as in, not Alice) should have received an email notification.
$notifyArgs
=
[
$alice
,
$title
,
'20200624000000'
,
''
,
false
];
$sent
=
$this
->
emailNotification
->
notifyOnPageChange
(
...
$notifyArgs
);
static
::
assertTrue
(
$sent
);
// Alice edits again, but Bob shouldn't be notified again
// (only one email until Bob visits the page again).
$sent
=
$this
->
emailNotification
->
notifyOnPageChange
(
...
$notifyArgs
);
static
::
assertFalse
(
$sent
);
// Reset notification timestamp, simulating that Bob visited the page.
$store
->
resetAllNotificationTimestampsForUser
(
$bob
);
// Bob re-watches temporarily. For testing purposes we use a past expiry,
// so an email shouldn't be sent after Alice edits the page.
$store
->
addWatch
(
$bob
,
$title
,
'20060123000000'
);
// Alice edits again, email should not be sent.
$sent
=
$this
->
emailNotification
->
notifyOnPageChange
(
...
$notifyArgs
);
static
::
assertFalse
(
$sent
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 18 2026, 03:19 (9 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e9/50/fbd077535ade44e8f1ae30384cbb
Default Alt Text
EmailNotificationTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment