MediaWiki REL1_31
ParserOutputSearchDataExtractorTest.php
Go to the documentation of this file.
1<?php
2
4
10
11 public function testGetCategories() {
12 $categories = [
13 'Foo_bar' => 'Bar',
14 'New_page' => ''
15 ];
16
17 $parserOutput = new ParserOutput( '', [], $categories );
18
19 $searchDataExtractor = new ParserOutputSearchDataExtractor();
20
21 $this->assertEquals(
22 [ 'Foo bar', 'New page' ],
23 $searchDataExtractor->getCategories( $parserOutput )
24 );
25 }
26
27 public function testGetExternalLinks() {
28 $parserOutput = new ParserOutput();
29
30 $parserOutput->addExternalLink( 'https://foo' );
31 $parserOutput->addExternalLink( 'https://bar' );
32
33 $searchDataExtractor = new ParserOutputSearchDataExtractor();
34
35 $this->assertEquals(
36 [ 'https://foo', 'https://bar' ],
37 $searchDataExtractor->getExternalLinks( $parserOutput )
38 );
39 }
40
41 public function testGetOutgoingLinks() {
42 $parserOutput = new ParserOutput();
43
44 $parserOutput->addLink( Title::makeTitle( NS_MAIN, 'Foo_bar' ), 1 );
45 $parserOutput->addLink( Title::makeTitle( NS_HELP, 'Contents' ), 2 );
46
47 $searchDataExtractor = new ParserOutputSearchDataExtractor();
48
49 // this indexes links with db key
50 $this->assertEquals(
51 [ 'Foo_bar', 'Help:Contents' ],
52 $searchDataExtractor->getOutgoingLinks( $parserOutput )
53 );
54 }
55
56 public function testGetTemplates() {
57 $title = Title::makeTitle( NS_TEMPLATE, 'Cite_news' );
58
59 $parserOutput = new ParserOutput();
60 $parserOutput->addTemplate( $title, 10, 100 );
61
62 $searchDataExtractor = new ParserOutputSearchDataExtractor();
63
64 $this->assertEquals(
65 [ 'Template:Cite news' ],
66 $searchDataExtractor->getTemplates( $parserOutput )
67 );
68 }
69
70}
Base class that store and restore the Language objects.
Extracts data from ParserOutput for indexing in the search engine.
Search MediaWiki\Search\ParserOutputSearchDataExtractor.
const NS_HELP
Definition Defines.php:86
const NS_MAIN
Definition Defines.php:74
const NS_TEMPLATE
Definition Defines.php:84