17 protected function assertMoved( $from, $to, $id, $opts =
null ) {
23 $this->assertTrue( $toTitle->exists(),
24 "Destination {$toTitle->getPrefixedText()} does not exist" );
26 if ( in_array(
'noredirect', $opts ) ) {
27 $this->assertFalse( $fromTitle->exists(),
28 "Source {$fromTitle->getPrefixedText()} exists" );
30 $this->assertTrue( $fromTitle->exists(),
31 "Source {$fromTitle->getPrefixedText()} does not exist" );
32 $this->assertTrue( $fromTitle->isRedirect(),
33 "Source {$fromTitle->getPrefixedText()} is not a redirect" );
36 $this->assertSame( $toTitle->getPrefixedText(), $target->getPrefixedText() );
39 $this->assertSame( $id, $toTitle->getArticleId() );
49 return $this->
editPage(
$name,
'Content' )->value[
'revision']->getPage();
54 'The parameters "from" and "fromid" can not be used together.' );
58 'from' =>
'Some page',
60 'to' =>
'Some other page',
65 $name = ucfirst( __FUNCTION__ );
76 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
80 $name = ucfirst( __FUNCTION__ );
91 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
96 "The page you specified doesn't exist." );
100 'from' =>
'Nonexistent page',
101 'to' =>
'Different page'
107 'There is no page with ID 2147483647.' );
111 'fromid' => pow( 2, 31 ) - 1,
112 'to' =>
'Different page',
119 $name = ucfirst( __FUNCTION__ );
139 "You've exceeded your rate limit. Please wait some time and try again." );
141 $name = ucfirst( __FUNCTION__ );
146 $wgRateLimits[
'move'] = [
'&can-bypass' =>
false,
'user' => [ 1, 60 ] ];
157 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
168 "\"$name 3\" should not exist" );
174 'You do not have permission to apply change tags along with your changes.' );
176 $name = ucfirst( __FUNCTION__ );
189 'tags' =>
'custom tag',
194 "\"$name 2\" should not exist" );
200 'The title is the same; cannot move a page over itself.' );
202 $name = ucfirst( __FUNCTION__ );
213 $name = ucfirst( __FUNCTION__ );
226 $this->
assertMoved(
"Talk:$name",
"Talk:$name 2", $talkId );
228 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
232 $name = ucfirst( __FUNCTION__ );
236 $talkDestinationId = $this->
createPage(
"Talk:$name 2" );
247 $this->assertSame( $talkDestinationId,
249 $this->assertSame( [ [
250 'message' =>
'articleexists',
252 'code' =>
'articleexists',
254 ] ],
$res[0][
'move'][
'talkmove-errors'] );
256 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
262 $name = ucfirst( __FUNCTION__ );
265 $wgNamespacesWithSubpages[
NS_MAIN] =
true;
267 $pages = [
$name,
"$name/1",
"$name/2",
"Talk:$name",
"Talk:$name/1",
"Talk:$name/3" ];
269 foreach ( array_merge( $pages, [
"$name/error",
"$name 2/error" ] )
as $page ) {
278 'movesubpages' =>
'',
281 foreach ( $pages
as $page ) {
282 $this->
assertMoved( $page, str_replace(
$name,
"$name 2", $page ), $ids[$page] );
285 $this->assertSame( $ids[
"$name/error"],
287 $this->assertSame( $ids[
"$name 2/error"],
290 $results = array_merge(
$res[0][
'move'][
'subpages'],
$res[0][
'move'][
'subpages-talk'] );
291 foreach ( $results
as $arr ) {
292 if ( $arr[
'from'] ===
"$name/error" ) {
293 $this->assertSame( [ [
294 'message' =>
'articleexists',
296 'code' =>
'articleexists',
298 ] ], $arr[
'errors'] );
300 $this->assertSame( str_replace(
$name,
"$name 2", $arr[
'from'] ), $arr[
'to'] );
302 $this->assertCount( 2, $arr );
305 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
310 'You must be a registered user and [[Special:UserLogin|logged in]] to move a page.' );
312 $name = ucfirst( __FUNCTION__ );
327 "\"$name 2\" should not exist" );
332 $name = ucfirst( __FUNCTION__ );
344 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
348 $name = ucfirst( __FUNCTION__ );
362 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
366 $name = ucfirst( __FUNCTION__ );
374 'from' =>
"Talk:$name",
376 'movesubpages' =>
'',
382 "\"$name/1\" should not exist" );
384 $this->assertSame( [
'errors' => [ [
385 'message' =>
'namespace-nosubpages',
387 'code' =>
'namespace-nosubpages',
389 ] ] ],
$res[0][
'move'][
'subpages'] );
391 $this->assertArrayNotHasKey(
'warnings',
$res[0] );