MediaWiki
REL1_31
ParserOutputSearchDataExtractorTest.php
Go to the documentation of this file.
1
<?php
2
3
use
MediaWiki\Search\ParserOutputSearchDataExtractor
;
4
9
class
ParserOutputSearchDataExtractorTest
extends
MediaWikiLangTestCase
{
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
}
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition
MediaWikiLangTestCase.php:6
MediaWiki\Search\ParserOutputSearchDataExtractor
Extracts data from ParserOutput for indexing in the search engine.
Definition
ParserOutputSearchDataExtractor.php:29
ParserOutputSearchDataExtractorTest
Search MediaWiki\Search\ParserOutputSearchDataExtractor.
Definition
ParserOutputSearchDataExtractorTest.php:9
ParserOutputSearchDataExtractorTest\testGetCategories
testGetCategories()
Definition
ParserOutputSearchDataExtractorTest.php:11
ParserOutputSearchDataExtractorTest\testGetOutgoingLinks
testGetOutgoingLinks()
Definition
ParserOutputSearchDataExtractorTest.php:41
ParserOutputSearchDataExtractorTest\testGetExternalLinks
testGetExternalLinks()
Definition
ParserOutputSearchDataExtractorTest.php:27
ParserOutputSearchDataExtractorTest\testGetTemplates
testGetTemplates()
Definition
ParserOutputSearchDataExtractorTest.php:56
ParserOutput
Definition
ParserOutput.php:25
NS_HELP
const NS_HELP
Definition
Defines.php:86
NS_MAIN
const NS_MAIN
Definition
Defines.php:74
NS_TEMPLATE
const NS_TEMPLATE
Definition
Defines.php:84
tests
phpunit
includes
search
ParserOutputSearchDataExtractorTest.php
Generated on Mon Nov 25 2024 15:36:33 for MediaWiki by
1.10.0