11 'By default nothing is merged' => [
16 'A simple merge policy adds the redirect data in' => [
17 function ( $current, $new ) {
18 if ( !isset( $current[
'index'] ) || $new[
'index'] < $current[
'index'] ) {
19 $current[
'index'] = $new[
'index'];
33 $pageSet->setRedirectMergePolicy( $mergePolicy );
35 $target->getArticleID() => []
37 $pageSet->populateGeneratorData(
$result );
38 $this->assertEquals( $expect,
$result[$target->getArticleID()] );
46 $pageSet->setRedirectMergePolicy( $mergePolicy );
48 $result->addValue(
null,
'pages', [
49 $target->getArticleID() => []
51 $pageSet->populateGeneratorData(
$result, [
'pages' ] );
54 $result->getResultData( [
'pages', $target->getArticleID() ] )
63 self::editPage(
'UTRedirectSourceA',
'#REDIRECT [[UTRedirectTarget]]' );
64 self::editPage(
'UTRedirectSourceB',
'#REDIRECT [[UTRedirectTarget]]' );
72 $pageSet->setGeneratorData( $sourceA, [
'index' => 1 ] );
73 $pageSet->setGeneratorData( $sourceB, [
'index' => 3 ] );
74 $pageSet->populateFromTitles( [ $sourceA, $sourceB ] );
76 return [ $target, $pageSet ];
87 [ 0 => [
'A' => -1,
'B' => -2,
'Å' => -3 ] ],
88 $pageSet->getAllTitlesByNamespace()
92 [
'fromencoded' =>
true,
'from' =>
'a%CC%8A',
'to' =>
'å' ],
93 [
'fromencoded' =>
false,
'from' =>
'a',
'to' =>
'A' ],
94 [
'fromencoded' =>
false,
'from' =>
'å',
'to' =>
'Å' ],
96 $pageSet->getNormalizedTitlesAsResult()
101 $id1 =
self::editPage(
'UTApiPageSet',
'UTApiPageSet in the default language' )
102 ->value[
'revision']->getTitle()->getArticleID();
103 $id2 =
self::editPage(
'UTApiPageSet/de',
'UTApiPageSet in German' )
104 ->value[
'revision']->getTitle()->getArticleID();
107 $userName =
$user->getName();
108 $userDbkey = str_replace(
' ',
'_', $userName );
110 'titles' => join(
'|', [
111 'Special:MyContributions',
113 'Special:MyTalk/subpage',
114 'Special:MyLanguage/UTApiPageSet',
125 $this->assertEquals( [
126 ], $pageSet->getRedirectTitlesAsResult() );
127 $this->assertEquals( [
128 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
129 [
'ns' => -1,
'title' =>
'Special:MyPage',
'special' =>
true ],
130 [
'ns' => -1,
'title' =>
'Special:MyTalk/subpage',
'special' =>
true ],
131 [
'ns' => -1,
'title' =>
'Special:MyLanguage/UTApiPageSet',
'special' =>
true ],
132 ], $pageSet->getInvalidTitlesAndRevisions() );
133 $this->assertEquals( [
134 ], $pageSet->getAllTitlesByNamespace() );
141 $this->assertEquals( [
142 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
143 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
144 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet' ],
145 ], $pageSet->getRedirectTitlesAsResult() );
146 $this->assertEquals( [
147 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
148 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
149 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
150 ], $pageSet->getInvalidTitlesAndRevisions() );
151 $this->assertEquals( [
152 0 => [
'UTApiPageSet' => $id1 ],
153 2 => [ $userDbkey => -2 ],
154 3 => [
"$userDbkey/subpage" => -3 ],
155 ], $pageSet->getAllTitlesByNamespace() );
162 $this->assertEquals( [
163 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
164 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
165 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet/de' ],
166 ], $pageSet->getRedirectTitlesAsResult() );
167 $this->assertEquals( [
168 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
169 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
170 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
171 ], $pageSet->getInvalidTitlesAndRevisions() );
172 $this->assertEquals( [
173 0 => [
'UTApiPageSet/de' => $id2 ],
174 2 => [ $userDbkey => -2 ],
175 3 => [
"$userDbkey/subpage" => -3 ],
176 ], $pageSet->getAllTitlesByNamespace() );