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__ );
137 "You've exceeded your rate limit. Please wait some time and try again." );
139 $name = ucfirst( __FUNCTION__ );
144 [
'move' => [
'&can-bypass' =>
false,
'user' => [ 1, 60 ] ] ] );
155 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
166 "\"$name 3\" should not exist" );
172 'You do not have permission to apply change tags along with your changes.' );
174 $name = ucfirst( __FUNCTION__ );
187 'tags' =>
'custom tag',
192 "\"$name 2\" should not exist" );
198 'The title is the same; cannot move a page over itself.' );
200 $name = ucfirst( __FUNCTION__ );
211 $name = ucfirst( __FUNCTION__ );
224 $this->
assertMoved(
"Talk:$name",
"Talk:$name 2", $talkId );
226 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
230 $name = ucfirst( __FUNCTION__ );
234 $talkDestinationId = $this->
createPage(
"Talk:$name 2" );
245 $this->assertSame( $talkDestinationId,
247 $this->assertSame( [ [
248 'message' =>
'articleexists',
250 'code' =>
'articleexists',
252 ] ],
$res[0][
'move'][
'talkmove-errors'] );
254 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
258 $name = ucfirst( __FUNCTION__ );
262 $pages = [
$name,
"$name/1",
"$name/2",
"Talk:$name",
"Talk:$name/1",
"Talk:$name/3" ];
264 foreach ( array_merge( $pages, [
"$name/error",
"$name 2/error" ] )
as $page ) {
273 'movesubpages' =>
'',
276 foreach ( $pages
as $page ) {
277 $this->
assertMoved( $page, str_replace(
$name,
"$name 2", $page ), $ids[$page] );
280 $this->assertSame( $ids[
"$name/error"],
282 $this->assertSame( $ids[
"$name 2/error"],
285 $results = array_merge(
$res[0][
'move'][
'subpages'],
$res[0][
'move'][
'subpages-talk'] );
286 foreach ( $results
as $arr ) {
287 if ( $arr[
'from'] ===
"$name/error" ) {
288 $this->assertSame( [ [
289 'message' =>
'articleexists',
291 'code' =>
'articleexists',
293 ] ], $arr[
'errors'] );
295 $this->assertSame( str_replace(
$name,
"$name 2", $arr[
'from'] ), $arr[
'to'] );
297 $this->assertCount( 2, $arr );
300 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
305 'You must be a registered user and [[Special:UserLogin|logged in]] to move a page.' );
307 $name = ucfirst( __FUNCTION__ );
322 "\"$name 2\" should not exist" );
327 $name = ucfirst( __FUNCTION__ );
339 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
343 $name = ucfirst( __FUNCTION__ );
357 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
361 $name = ucfirst( __FUNCTION__ );
369 'from' =>
"Talk:$name",
371 'movesubpages' =>
'',
377 "\"$name/1\" should not exist" );
379 $this->assertSame( [
'errors' => [ [
380 'message' =>
'namespace-nosubpages',
382 'code' =>
'namespace-nosubpages',
384 ] ] ],
$res[0][
'move'][
'subpages'] );
386 $this->assertArrayNotHasKey(
'warnings',
$res[0] );