3 use MediaWiki\Search\ParserOutputSearchDataExtractor
;
7 * @covers MediaWiki\Search\ParserOutputSearchDataExtractor
9 class ParserOutputSearchDataExtractorTest
extends MediaWikiLangTestCase
{
11 public function testGetCategories() {
17 $parserOutput = new ParserOutput( '', [], $categories );
19 $searchDataExtractor = new ParserOutputSearchDataExtractor();
22 [ 'Foo bar', 'New page' ],
23 $searchDataExtractor->getCategories( $parserOutput )
27 public function testGetExternalLinks() {
28 $parserOutput = new ParserOutput();
30 $parserOutput->addExternalLink( 'https://foo' );
31 $parserOutput->addExternalLink( 'https://bar' );
33 $searchDataExtractor = new ParserOutputSearchDataExtractor();
36 [ 'https://foo', 'https://bar' ],
37 $searchDataExtractor->getExternalLinks( $parserOutput )
41 public function testGetOutgoingLinks() {
42 $parserOutput = new ParserOutput();
44 $parserOutput->addLink( Title
::makeTitle( NS_MAIN
, 'Foo_bar' ), 1 );
45 $parserOutput->addLink( Title
::makeTitle( NS_HELP
, 'Contents' ), 2 );
47 $searchDataExtractor = new ParserOutputSearchDataExtractor();
49 // this indexes links with db key
51 [ 'Foo_bar', 'Help:Contents' ],
52 $searchDataExtractor->getOutgoingLinks( $parserOutput )
56 public function testGetTemplates() {
57 $title = Title
::makeTitle( NS_TEMPLATE
, 'Cite_news' );
59 $parserOutput = new ParserOutput();
60 $parserOutput->addTemplate( $title, 10, 100 );
62 $searchDataExtractor = new ParserOutputSearchDataExtractor();
65 [ 'Template:Cite news' ],
66 $searchDataExtractor->getTemplates( $parserOutput )