Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432019
ApiDiscussionToolsPageInfoTest.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
ApiDiscussionToolsPageInfoTest.php
View Options
<?php
namespace
MediaWiki\Extension\DiscussionTools\Tests
;
use
MediaWiki\Extension\DiscussionTools\ApiDiscussionToolsPageInfo
;
use
MediaWiki\Tests\Api\ApiTestCase
;
use
Wikimedia\TestingAccessWrapper
;
/**
* @group medium
* @group Database
* @covers \MediaWiki\Extension\DiscussionTools\ApiDiscussionToolsPageInfo
*/
class
ApiDiscussionToolsPageInfoTest
extends
ApiTestCase
{
use
TestUtils
;
/**
* @dataProvider provideGetThreadItemsHtml
*/
public
function
testGetThreadItemsHtml
(
string
$name
,
string
$title
,
string
$dom
,
string
$expected
,
string
$config
,
string
$data
):
void
{
$dom
=
static
::
getHtml
(
$dom
);
$expectedPath
=
$expected
;
$expected
=
static
::
getJson
(
$expected
);
$config
=
static
::
getJson
(
$config
);
$data
=
static
::
getJson
(
$data
);
$doc
=
static
::
createDocument
(
$dom
);
$container
=
static
::
getThreadContainer
(
$doc
);
$title
=
$this
->
getServiceContainer
()->
getTitleParser
()->
parseTitle
(
$title
);
$threadItemSet
=
$this
->
createParser
(
$config
,
$data
)->
parse
(
$container
,
$title
);
$pageInfo
=
TestingAccessWrapper
::
newFromClass
(
ApiDiscussionToolsPageInfo
::
class
);
$threadItemsHtml
=
$pageInfo
->
getThreadItemsHtml
(
$threadItemSet
,
false
);
// Optionally write updated content to the JSON files
if
(
getenv
(
'DISCUSSIONTOOLS_OVERWRITE_TESTS'
)
)
{
static
::
overwriteJsonFile
(
$expectedPath
,
$threadItemsHtml
);
}
static
::
assertEquals
(
$expected
,
$threadItemsHtml
,
$name
);
}
public
static
function
provideGetThreadItemsHtml
():
array
{
return
static
::
getJson
(
'../cases/threaditemshtml.json'
);
}
/**
* @covers \MediaWiki\Extension\DiscussionTools\ApiDiscussionToolsPageInfo::execute
*/
public
function
testExecuteApiDiscussionToolsPageInfo
()
{
$page
=
$this
->
getNonexistingTestPage
(
__METHOD__
);
$this
->
editPage
(
$page
,
'add DT pageinfo content'
);
$params
=
[
'action'
=>
'discussiontoolspageinfo'
,
'page'
=>
$page
->
getTitle
()->
getText
(),
];
$result
=
$this
->
doApiRequestWithToken
(
$params
);
$this
->
assertNotEmpty
(
$result
[
0
][
'discussiontoolspageinfo'
]
);
$this
->
assertArrayHasKey
(
'transcludedfrom'
,
$result
[
0
][
'discussiontoolspageinfo'
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:20 (1 d, 5 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
47/41/85e22cd131b785db14aa6725dab9
Default Alt Text
ApiDiscussionToolsPageInfoTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment