Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5958179
MiddlewareChainTest.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
MiddlewareChainTest.php
View Options
<?php
/**
* @license GPL-2.0-or-later
* @file
*/
namespace
MediaWiki\Tests\Integration\Notification
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Notification\MiddlewareException
;
use
MediaWiki\Notification\Notification
;
use
MediaWiki\Notification\NotificationMiddlewareInterface
;
use
MediaWiki\Notification\RecipientSet
;
use
MediaWiki\Registration\ExtensionRegistry
;
use
MediaWiki\User\UserIdentity
;
use
MediaWikiIntegrationTestCase
;
use
Wikimedia\ScopedCallback
;
/**
* @group Mail
* @covers \MediaWiki\Notification\MiddlewareChain
*/
class
MiddlewareChainTest
extends
MediaWikiIntegrationTestCase
{
/**
* Test case when Middleware calls NotificationService::notify() to inject new notification
* This can cause endless loops where Middleware triggers a notification, that triggers the
* middleware again.
*
* @return void
*/
public
function
testMiddlewareCannotTriggerNotificationService
()
{
$this
->
expectException
(
MiddlewareException
::
class
);
$scope
=
ExtensionRegistry
::
getInstance
()->
setAttributeForTest
(
'NotificationMiddleware'
,
[
[
"factory"
=>
static
function
()
{
return
new
class
implements
NotificationMiddlewareInterface
{
public
function
handle
(
$batch
,
callable
$next
):
void
{
MediaWikiServices
::
getInstance
()
->
getNotificationService
()
->
notify
(
new
Notification
(
"bad"
),
new
RecipientSet
(
[]
)
);
$next
();
}
};
},
],
]
);
$sut
=
MediaWikiServices
::
getInstance
()->
getNotificationService
();
$user
=
$this
->
createMock
(
UserIdentity
::
class
);
$sut
->
notify
(
new
Notification
(
"good"
),
new
RecipientSet
(
[
$user
]
)
);
ScopedCallback
::
consume
(
$scope
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 05:37 (2 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4d/22/3d3b869ca32c0d70b229f2856710
Default Alt Text
MiddlewareChainTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment