wiki.techinc.nl/tests/phpunit/integration/includes/block/UnblockUserTest.php
Bartosz Dziewoński 13289a1269 Use real type hints for services etc. in includes/block/
Mostly used find-and-replace:

Find:
/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|)
Replace with:
\3 \1 \4

More could be done, but to keep this patch reasonably sized, I only
changed the most obvious and unambiguously correct cases.

In some cases, I also removed redundant doc comments on the
constructor, and re-ordered the properties to match the constructor.

Change-Id: I819ed771c915293663856c577a481d607b76ed80
2024-07-31 08:54:31 +00:00

70 lines
1.7 KiB
PHP

<?php
namespace MediaWiki\Tests\Block;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\UnblockUserFactory;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
use MediaWiki\User\User;
use MediaWikiIntegrationTestCase;
/**
* @group Blocking
* @group Database
*/
class UnblockUserTest extends MediaWikiIntegrationTestCase {
use MockAuthorityTrait;
private User $user;
private UnblockUserFactory $unblockUserFactory;
protected function setUp(): void {
parent::setUp();
// Prepare users
$this->user = $this->getTestUser()->getUser();
// Prepare factory
$this->unblockUserFactory = $this->getServiceContainer()->getUnblockUserFactory();
}
/**
* @covers \MediaWiki\Block\UnblockUser::unblock
*/
public function testValidUnblock() {
$performer = $this->mockRegisteredUltimateAuthority();
$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->assertStatusError( 'ipb_cant_unblock', $status );
}
}