MediaWiki REL1_32
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}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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:76
const NS_MAIN
Definition Defines.php:64
const NS_TEMPLATE
Definition Defines.php:74
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37