12 'By default nothing is merged' => [
17 'A simple merge policy adds the redirect data in' => [
18 function ( $current, $new ) {
19 if ( !isset( $current[
'index'] ) || $new[
'index'] < $current[
'index'] ) {
20 $current[
'index'] = $new[
'index'];
34 $pageSet->setRedirectMergePolicy( $mergePolicy );
36 $target->getArticleID() => []
38 $pageSet->populateGeneratorData(
$result );
39 $this->assertEquals( $expect,
$result[$target->getArticleID()] );
47 $pageSet->setRedirectMergePolicy( $mergePolicy );
49 $result->addValue(
null,
'pages', [
50 $target->getArticleID() => []
52 $pageSet->populateGeneratorData(
$result, [
'pages' ] );
55 $result->getResultData( [
'pages', $target->getArticleID() ] )
64 self::editPage(
'UTRedirectSourceA',
'#REDIRECT [[UTRedirectTarget]]' );
65 self::editPage(
'UTRedirectSourceB',
'#REDIRECT [[UTRedirectTarget]]' );
73 $pageSet->setGeneratorData( $sourceA, [
'index' => 1 ] );
74 $pageSet->setGeneratorData( $sourceB, [
'index' => 3 ] );
75 $pageSet->populateFromTitles( [ $sourceA, $sourceB ] );
77 return [ $target, $pageSet ];
88 [ 0 => [
'A' => -1,
'B' => -2,
'Å' => -3 ] ],
89 $pageSet->getAllTitlesByNamespace()
93 [
'fromencoded' =>
true,
'from' =>
'a%CC%8A',
'to' =>
'å' ],
94 [
'fromencoded' =>
false,
'from' =>
'a',
'to' =>
'A' ],
95 [
'fromencoded' =>
false,
'from' =>
'å',
'to' =>
'Å' ],
97 $pageSet->getNormalizedTitlesAsResult()
102 $id1 =
self::editPage(
'UTApiPageSet',
'UTApiPageSet in the default language' )
103 ->value[
'revision']->getTitle()->getArticleID();
104 $id2 =
self::editPage(
'UTApiPageSet/de',
'UTApiPageSet in German' )
105 ->value[
'revision']->getTitle()->getArticleID();
108 $userName =
$user->getName();
109 $userDbkey = str_replace(
' ',
'_', $userName );
111 'titles' => implode(
'|', [
112 'Special:MyContributions',
114 'Special:MyTalk/subpage',
115 'Special:MyLanguage/UTApiPageSet',
126 $this->assertEquals( [
127 ], $pageSet->getRedirectTitlesAsResult() );
128 $this->assertEquals( [
129 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
130 [
'ns' => -1,
'title' =>
'Special:MyPage',
'special' =>
true ],
131 [
'ns' => -1,
'title' =>
'Special:MyTalk/subpage',
'special' =>
true ],
132 [
'ns' => -1,
'title' =>
'Special:MyLanguage/UTApiPageSet',
'special' =>
true ],
133 ], $pageSet->getInvalidTitlesAndRevisions() );
134 $this->assertEquals( [
135 ], $pageSet->getAllTitlesByNamespace() );
142 $this->assertEquals( [
143 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
144 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
145 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet' ],
146 ], $pageSet->getRedirectTitlesAsResult() );
147 $this->assertEquals( [
148 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
149 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
150 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
151 ], $pageSet->getInvalidTitlesAndRevisions() );
152 $this->assertEquals( [
153 0 => [
'UTApiPageSet' => $id1 ],
154 2 => [ $userDbkey => -2 ],
155 3 => [
"$userDbkey/subpage" => -3 ],
156 ], $pageSet->getAllTitlesByNamespace() );
163 $this->assertEquals( [
164 [
'from' =>
'Special:MyPage',
'to' =>
"User:$userName" ],
165 [
'from' =>
'Special:MyTalk/subpage',
'to' =>
"User talk:$userName/subpage" ],
166 [
'from' =>
'Special:MyLanguage/UTApiPageSet',
'to' =>
'UTApiPageSet/de' ],
167 ], $pageSet->getRedirectTitlesAsResult() );
168 $this->assertEquals( [
169 [
'ns' => -1,
'title' =>
'Special:MyContributions',
'special' =>
true ],
170 [
'ns' => 2,
'title' =>
"User:$userName",
'missing' =>
true ],
171 [
'ns' => 3,
'title' =>
"User talk:$userName/subpage",
'missing' =>
true ],
172 ], $pageSet->getInvalidTitlesAndRevisions() );
173 $this->assertEquals( [
174 0 => [
'UTApiPageSet/de' => $id2 ],
175 2 => [ $userDbkey => -2 ],
176 3 => [
"$userDbkey/subpage" => -3 ],
177 ], $pageSet->getAllTitlesByNamespace() );