mediawiki-extensions-Discus.../tests/phpunit/integration/ApiParseDiscussionToolsTest.php
C. Scott Ananian 086ce6550f Don't rely on ParserOutput::getTOCHTML() to determine if ToC is present
ParserOutput::getTOCHTML() is being deprecated, and all skins are now
generating the TOC from the TOCData returned by
ParserOutput::getTOCData().  The SHOW_TOC flag was introduced in core
to determine if the TOC should be shown, but Vector-2022 *may* begin to
use other heuristics to determine whether to show the TOC (T315862).
We're conservatively going to process the TOC as long as there is
TOC present to process.

Bug: T328072
Change-Id: I38b439c6752157dbee9b09c9f5443a740dbaabf4
2023-01-27 09:58:47 +00:00

35 lines
742 B
PHP

<?php
namespace MediaWiki\Extension\DiscussionTools\Tests;
use ApiTestCase;
/**
* @group medium
* @group Database
*/
class ApiParseDiscussionToolsTest extends ApiTestCase {
/**
* @covers \MediaWiki\Extension\DiscussionTools\CommentFormatter::addDiscussionTools
*/
public function testApiParseSections() {
$params = [
'action' => 'parse',
'title' => 'Talk:Test',
'uselang' => 'en',
'text' => "__FORCETOC__\n== foo ==\nbar ~~~~",
'pst' => 1,
'prop' => 'sections',
];
[ $result, ] = $this->doApiRequest( $params );
$this->assertSame(
'<span class="ext-discussiontools-init-sidebar-meta">1 comment</span>',
$result['parse']['sections'][0]['extensionData']['DiscussionTools-html-summary']
);
}
}