17 protected function assertMoved( $from, $to, $id, $opts =
null ) {
24 $this->assertTrue( $toTitle->exists(),
25 "Destination {$toTitle->getPrefixedText()} does not exist" );
27 if ( in_array(
'noredirect', $opts ) ) {
28 $this->assertFalse( $fromTitle->exists(),
29 "Source {$fromTitle->getPrefixedText()} exists" );
31 $this->assertTrue( $fromTitle->exists(),
32 "Source {$fromTitle->getPrefixedText()} does not exist" );
33 $this->assertTrue( $fromTitle->isRedirect(),
34 "Source {$fromTitle->getPrefixedText()} is not a redirect" );
37 $this->assertSame( $toTitle->getPrefixedText(), $target->getPrefixedText() );
40 $this->assertSame( $id, $toTitle->getArticleID() );
50 return $this->
editPage(
$name,
'Content' )->value[
'revision']->getPage();
55 'The parameters "from" and "fromid" can not be used together.' );
59 'from' =>
'Some page',
61 'to' =>
'Some other page',
66 $name = ucfirst( __FUNCTION__ );
77 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
81 $name = ucfirst( __FUNCTION__ );
92 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
97 "The page you specified doesn't exist." );
101 'from' =>
'Nonexistent page',
102 'to' =>
'Different page'
108 'There is no page with ID 2147483647.' );
112 'fromid' => pow( 2, 31 ) - 1,
113 'to' =>
'Different page',
120 $name = ucfirst( __FUNCTION__ );
137 $block =
new Block( [
138 'address' => self::$users[
'sysop']->getUser()->getName(),
139 'by' => self::$users[
'sysop']->getUser()->getId(),
140 'reason' =>
'Capriciousness',
141 'timestamp' =>
'19370101000000',
142 'expiry' =>
'infinity',
143 'enableAutoblock' =>
true,
147 $name = ucfirst( __FUNCTION__ );
156 $this->fail(
'Expected exception not thrown' );
158 $this->assertSame(
'You have been blocked from editing.', $ex->getMessage() );
162 self::$users[
'sysop']->getUser()->clearInstanceCache();
171 "You've exceeded your rate limit. Please wait some time and try again." );
173 $name = ucfirst( __FUNCTION__ );
178 [
'move' => [
'&can-bypass' =>
false,
'user' => [ 1, 60 ] ] ] );
189 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
200 "\"$name 3\" should not exist" );
206 'You do not have permission to apply change tags along with your changes.' );
208 $name = ucfirst( __FUNCTION__ );
221 'tags' =>
'custom tag',
226 "\"$name 2\" should not exist" );
232 'The title is the same; cannot move a page over itself.' );
234 $name = ucfirst( __FUNCTION__ );
245 $name = ucfirst( __FUNCTION__ );
258 $this->
assertMoved(
"Talk:$name",
"Talk:$name 2", $talkId );
260 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
264 $name = ucfirst( __FUNCTION__ );
268 $talkDestinationId = $this->
createPage(
"Talk:$name 2" );
279 $this->assertSame( $talkDestinationId,
281 $this->assertSame( [ [
282 'message' =>
'articleexists',
284 'code' =>
'articleexists',
286 ] ],
$res[0][
'move'][
'talkmove-errors'] );
288 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
292 $name = ucfirst( __FUNCTION__ );
296 $pages = [
$name,
"$name/1",
"$name/2",
"Talk:$name",
"Talk:$name/1",
"Talk:$name/3" ];
298 foreach ( array_merge( $pages, [
"$name/error",
"$name 2/error" ] )
as $page ) {
307 'movesubpages' =>
'',
310 foreach ( $pages
as $page ) {
311 $this->
assertMoved( $page, str_replace(
$name,
"$name 2", $page ), $ids[$page] );
314 $this->assertSame( $ids[
"$name/error"],
316 $this->assertSame( $ids[
"$name 2/error"],
319 $results = array_merge(
$res[0][
'move'][
'subpages'],
$res[0][
'move'][
'subpages-talk'] );
320 foreach ( $results
as $arr ) {
321 if ( $arr[
'from'] ===
"$name/error" ) {
322 $this->assertSame( [ [
323 'message' =>
'articleexists',
325 'code' =>
'articleexists',
327 ] ], $arr[
'errors'] );
329 $this->assertSame( str_replace(
$name,
"$name 2", $arr[
'from'] ), $arr[
'to'] );
331 $this->assertCount( 2, $arr );
334 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
339 'You must be a registered user and [[Special:UserLogin|logged in]] to move a page.' );
341 $name = ucfirst( __FUNCTION__ );
356 "\"$name 2\" should not exist" );
361 $name = ucfirst( __FUNCTION__ );
373 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
377 $name = ucfirst( __FUNCTION__ );
391 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
395 $name = ucfirst( __FUNCTION__ );
403 'from' =>
"Talk:$name",
405 'movesubpages' =>
'',
411 "\"$name/1\" should not exist" );
413 $this->assertSame( [
'errors' => [ [
414 'message' =>
'namespace-nosubpages',
416 'code' =>
'namespace-nosubpages',
418 ] ] ],
$res[0][
'move'][
'subpages'] );
420 $this->assertArrayNotHasKey(
'warnings',
$res[0] );