MediaWiki REL1_28
MediaWikiPageNameNormalizerTest.php
Go to the documentation of this file.
1<?php
2
4
30class MediaWikiPageNameNormalizerTest extends PHPUnit_Framework_TestCase {
31
35 public function testNormalizePageTitle( $expected, $pageName, $getResponse ) {
37
38 $normalizer = new MediaWikiPageNameNormalizer(
40 );
41
42 $this->assertSame(
43 $expected,
44 $normalizer->normalizePageName( $pageName, 'https://www.wikidata.org/w/api.php' )
45 );
46 }
47
48 public function normalizePageTitleProvider() {
49 // Response are taken from wikidata and kkwiki using the following API request
50 // api.php?action=query&prop=info&redirects=1&converttitles=1&format=json&titles=…
51 return [
52 'universe (Q1)' => [
53 'Q1',
54 'Q1',
55 '{"batchcomplete":"","query":{"pages":{"129":{"pageid":129,"ns":0,'
56 . '"title":"Q1","contentmodel":"wikibase-item","pagelanguage":"en",'
57 . '"pagelanguagehtmlcode":"en","pagelanguagedir":"ltr",'
58 . '"touched":"2016-06-23T05:11:21Z","lastrevid":350004448,"length":58001}}}}'
59 ],
60 'Q404 redirects to Q395' => [
61 'Q395',
62 'Q404',
63 '{"batchcomplete":"","query":{"redirects":[{"from":"Q404","to":"Q395"}],"pages"'
64 . ':{"601":{"pageid":601,"ns":0,"title":"Q395","contentmodel":"wikibase-item",'
65 . '"pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr",'
66 . '"touched":"2016-06-23T08:00:20Z","lastrevid":350021914,"length":60108}}}}'
67 ],
68 'D converted to Д (Latin to Cyrillic) (taken from kkwiki)' => [
69 'Д',
70 'D',
71 '{"batchcomplete":"","query":{"converted":[{"from":"D","to":"\u0414"}],'
72 . '"pages":{"510541":{"pageid":510541,"ns":0,"title":"\u0414",'
73 . '"contentmodel":"wikitext","pagelanguage":"kk","pagelanguagehtmlcode":"kk",'
74 . '"pagelanguagedir":"ltr","touched":"2015-11-22T09:16:18Z",'
75 . '"lastrevid":2373618,"length":3501}}}}'
76 ],
77 'there is no Q0' => [
78 false,
79 'Q0',
80 '{"batchcomplete":"","query":{"pages":{"-1":{"ns":0,"title":"Q0",'
81 . '"missing":"","contentmodel":"wikibase-item","pagelanguage":"en",'
82 . '"pagelanguagehtmlcode":"en","pagelanguagedir":"ltr"}}}}'
83 ],
84 'invalid title' => [
85 false,
86 '{{',
87 '{"batchcomplete":"","query":{"pages":{"-1":{"title":"{{",'
88 . '"invalidreason":"The requested page title contains invalid '
89 . 'characters: \"{\".","invalid":""}}}}'
90 ],
91 'error on get' => [ false, 'ABC', false ]
92 ];
93 }
94
95}
96
102
106 public static $response;
107
108 public static function get( $url, $options = [], $caller = __METHOD__ ) {
109 PHPUnit_Framework_Assert::assertInternalType( 'string', $url );
110 PHPUnit_Framework_Assert::assertInternalType( 'array', $options );
111 PHPUnit_Framework_Assert::assertInternalType( 'string', $caller );
112
113 return self::$response;
114 }
115}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Various HTTP related functions.
Definition Http.php:27
MediaWiki\Site\MediaWikiPageNameNormalizer.
testNormalizePageTitle( $expected, $pageName, $getResponse)
normalizePageTitleProvider
Service for normalizing a page name using a MediaWiki api.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1096
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
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