* This should be kept in sync with TitleTest::provideTestIsValidMoveOperation
*/
public static function provideIsValidMove() {
- return array(
+ return [
// for MovePage::isValidMove
- array( 'Test', 'Test', 'selfmove' ),
- array( 'Special:FooBar', 'Test', 'immobile-source-namespace' ),
- array( 'Test', 'Special:FooBar', 'immobile-target-namespace' ),
- array( 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ),
- array( 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ),
+ [ 'Test', 'Test', 'selfmove' ],
+ [ 'Special:FooBar', 'Test', 'immobile-source-namespace' ],
+ [ 'Test', 'Special:FooBar', 'immobile-target-namespace' ],
+ [ 'MediaWiki:Common.js', 'Help:Some wikitext page', 'bad-target-model' ],
+ [ 'Page', 'File:Test.jpg', 'nonfile-cannot-move-to-file' ],
// for MovePage::isValidFileMove
- array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ),
- );
+ [ 'File:Test.jpg', 'Page', 'imagenocrossnamespace' ],
+ ];
}
/**
* Integration test to catch regressions like T74870. Taken and modified
* from SemanticMediaWiki
+ *
+ * @covers Title::moveTo
*/
public function testTitleMoveCompleteIntegrationTest() {
$oldTitle = Title::newFromText( 'Help:Some title' );
WikiPage::factory( $newTitle )->getRevision()
);
}
+
+ /**
+ * Test for the move operation being aborted via the TitleMove hook
+ */
+ public function testMoveAbortedByTitleMoveHook() {
+ $error = 'Preventing move operation with TitleMove hook.';
+ $this->setTemporaryHook( 'TitleMove',
+ function ( $old, $new, $user, $reason, $status ) use ( $error ) {
+ $status->fatal( $error );
+ }
+ );
+
+ $oldTitle = Title::newFromText( 'Some old title' );
+ WikiPage::factory( $oldTitle )->doEditContent( new WikitextContent( 'foo' ), 'bar' );
+ $newTitle = Title::newFromText( 'A brand new title' );
+ $mp = new MovePage( $oldTitle, $newTitle );
+ $user = User::newFromName( 'TitleMove tester' );
+ $status = $mp->move( $user, 'Reason', true );
+ $this->assertTrue( $status->hasMessage( $error ) );
+ }
}