X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FMovePageTest.php;h=1b2b159f0a025f52e8dd92b7e3b29837741e5b31;hb=9a708748deb1124eff394eaf0402a6a14d769b9c;hp=583b75184db992274076c2d259ecd6b58384e0c8;hpb=fd3f586dbbbb556aa19c0a53c7e8cb1aa93fa164;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/MovePageTest.php b/tests/phpunit/includes/MovePageTest.php index 583b75184d..1b2b159f0a 100644 --- a/tests/phpunit/includes/MovePageTest.php +++ b/tests/phpunit/includes/MovePageTest.php @@ -62,4 +62,25 @@ class MovePageTest extends MediaWikiTestCase { WikiPage::factory( $newTitle )->getRevision() ); } + + /** + * Test for the move operation being aborted via the TitleMove hook + * @covers MovePage::move + */ + 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 ) ); + } }