Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5937282
PageLinkedEventIntegrationTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PageLinkedEventIntegrationTest.php
View Options
<?php
/**
* @covers \MediaWiki\Extension\Notifications\Hooks::onLinksUpdateComplete
* @group Database
*/
class
PageLinkedEventIntegrationTest
extends
MediaWikiIntegrationTestCase
{
/**
* User who created a page should get a notification when a link to it is added on another page.
*/
public
function
testEventCreatedOnEdit
()
{
$this
->
clearHook
(
'BeforeEchoEventInsert'
);
$this
->
overrideConfigValue
(
'EchoUseJobQueue'
,
false
);
$creator
=
new
TestUser
(
'Creator'
);
$linker
=
new
TestUser
(
'Linker'
);
$this
->
editPage
(
'Target page'
,
''
,
''
,
NS_MAIN
,
$creator
->
getUser
()
);
$this
->
editPage
(
'Test page'
,
'[[Target page]]'
,
''
,
NS_MAIN
,
$linker
->
getUser
()
);
// Verify that an event was generated
$this
->
assertSelect
(
'echo_event'
,
[
'COUNT(*)'
],
[
'event_type'
=>
'page-linked'
],
[
[
'1'
]
]
);
}
private
function
importRevisions
(
$xml
,
$performer
)
{
$source
=
new
ImportStringSource
(
$xml
);
$importer
=
$this
->
getServiceContainer
()
->
getWikiImporterFactory
()
->
getWikiImporter
(
$source
,
$performer
);
// `true` means to assign edits to the test users we created
$importer
->
setUsernamePrefix
(
'import'
,
true
);
$importer
->
doImport
();
}
/**
* User who created a page should NOT get a notification when a link to it is added in an imported
* revision.
*/
public
function
testEventNotCreatedOnImport
()
{
$this
->
clearHook
(
'BeforeEchoEventInsert'
);
$this
->
overrideConfigValue
(
'EchoUseJobQueue'
,
false
);
$creator
=
new
TestUser
(
'Creator'
);
$linker
=
new
TestUser
(
'Linker'
);
$importer
=
new
TestUser
(
'Importer'
);
$this
->
editPage
(
'Target page'
,
''
,
''
,
NS_MAIN
,
$creator
->
getUser
()
);
// phpcs:disable Generic.Files.LineLength
$this
->
importRevisions
(
<<<
'XML'
<
mediawiki
xmlns
=
"http://www.mediawiki.org/xml/export-0.11/"
xmlns
:
xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xsi
:
schemaLocation
=
"http://www.mediawiki.org/xml/export-0.11/ http://www.mediawiki.org/xml/export-0.11.xsd"
version
=
"0.11"
xml
:
lang
=
"en"
>
<
page
>
<
title
>
Test
page
</
title
>
<
ns
>
0
</
ns
>
<
revision
>
<
contributor
>
<
username
>
Linker
</
username
>
</
contributor
>
<
text
xml
:
space
=
"preserve"
>[[
Target
page
]]</
text
>
<
timestamp
>
2021
-
02
-
03
T04
:
05
:
06
Z
</
timestamp
>
</
revision
>
</
page
>
</
mediawiki
>
XML
,
$importer
->
getUser
()
);
// phpcs:enable Generic.Files.LineLength
// Verify that the import worked
$this
->
assertSelect
(
'page'
,
[
'COUNT(*)'
],
[
'page_namespace'
=>
0
,
'page_title'
=>
'Test_page'
],
[
[
'1'
]
]
);
// Verify that no event was generated
$this
->
assertSelect
(
'echo_event'
,
[
'COUNT(*)'
],
[
'event_type'
=>
'page-linked'
],
[
[
'0'
]
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 2 2026, 15:50 (6 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
53/a3/490461ae99c2e7b90d25ca9a4140
Default Alt Text
PageLinkedEventIntegrationTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment