Merge "Add ability to pre-render thumbnails at upload time"
[lhc/web/wiklou.git] / tests / phpunit / includes / MovePageTest.php
1 <?php
2
3 class MovePageTest extends MediaWikiTestCase {
4
5 /**
6 * @dataProvider provideIsValidMove
7 * @covers MovePage::isValidMove
8 * @covers MovePage::isValidFileMove
9 */
10 public function testIsValidMove( $old, $new, $error ) {
11 $this->setMwGlobals( 'wgContentHandlerUseDB', false );
12 $mp = new MovePage(
13 Title::newFromText( $old ),
14 Title::newFromText( $new )
15 );
16 $status = $mp->isValidMove();
17 if ( $error === true ) {
18 $this->assertTrue( $status->isGood() );
19 } else {
20 $this->assertTrue( $status->hasMessage( $error ) );
21 }
22 }
23
24 /**
25 * This should be kept in sync with TitleTest::provideTestIsValidMoveOperation
26 */
27 public static function provideIsValidMove() {
28 return array(
29 // for MovePage::isValidMove
30 array( 'Test', 'Test', 'selfmove' ),
31 array( 'Special:FooBar', 'Test', 'immobile-source-namespace' ),
32 array( 'Test', 'Special:FooBar', 'immobile-target-namespace' ),
33 array( 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ),
34 array( 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ),
35 // for MovePage::isValidFileMove
36 array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ),
37 );
38 }
39 }