user = $this->getTestUser()->getUser(); // Prepare factory $this->unblockUserFactory = $this->getServiceContainer()->getUnblockUserFactory(); } /** * @covers \MediaWiki\Block\UnblockUser::unblock */ public function testValidUnblock() { $performer = $this->mockAnonUltimateAuthority(); $block = new DatabaseBlock( [ 'address' => $this->user->getName(), 'by' => $performer->getUser() ] ); $this->getServiceContainer()->getDatabaseBlockStore()->insertBlock( $block ); $this->assertInstanceOf( DatabaseBlock::class, $this->user->getBlock() ); $status = $this->unblockUserFactory->newUnblockUser( $this->user, $performer, 'test' )->unblock(); $this->assertStatusOK( $status ); $this->assertNotInstanceOf( DatabaseBlock::class, User::newFromName( $this->user->getName() ) ->getBlock() ); } /** * @covers \MediaWiki\Block\UnblockUser::unblockUnsafe */ public function testNotBlocked() { $this->user = User::newFromName( $this->user->getName() ); // Reload the user object $status = $this->unblockUserFactory->newUnblockUser( $this->user, $this->mockRegisteredUltimateAuthority(), 'test' )->unblock(); $this->assertStatusNotOK( $status ); $this->assertContains( 'ipb_cant_unblock', array_column( $status->getErrorsArray(), 0 ) ); } }