Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / search / ParserOutputSearchDataExtractorTest.php
blob69d0b76f2537402f00123b6cca729299e1f37423
1 <?php
3 use MediaWiki\Search\ParserOutputSearchDataExtractor;
5 /**
6 * @group Search
7 * @covers MediaWiki\Search\ParserOutputSearchDataExtractor
8 */
9 class ParserOutputSearchDataExtractorTest extends MediaWikiLangTestCase {
11 public function testGetCategories() {
12 $categories = [
13 'Foo_bar' => 'Bar',
14 'New_page' => ''
17 $parserOutput = new ParserOutput( '', [], $categories );
19 $searchDataExtractor = new ParserOutputSearchDataExtractor();
21 $this->assertEquals(
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();
35 $this->assertEquals(
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
50 $this->assertEquals(
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();
64 $this->assertEquals(
65 [ 'Template:Cite news' ],
66 $searchDataExtractor->getTemplates( $parserOutput )