<?php
+use MediaWiki\Block\DatabaseBlock;
+
/**
* @group API
* @group Database
$this->blockee = $this->getMutableTestUser()->getUser();
// Initialize a blocked user (used by most tests, although not all)
- $block = new Block( [
+ $block = new DatabaseBlock( [
'address' => $this->blockee->getName(),
'by' => $this->blocker->getId(),
] );
$result = $block->insert();
$this->assertNotFalse( $result, 'Could not insert block' );
- $blockFromDB = Block::newFromID( $result['id'] );
+ $blockFromDB = DatabaseBlock::newFromID( $result['id'] );
$this->assertTrue( !is_null( $blockFromDB ), 'Could not retrieve block' );
}
private function getBlockFromParams( array $params ) {
if ( array_key_exists( 'user', $params ) ) {
- return Block::newFromTarget( $params['user'] );
+ return DatabaseBlock::newFromTarget( $params['user'] );
}
if ( array_key_exists( 'userid', $params ) ) {
- return Block::newFromTarget( User::newFromId( $params['userid'] ) );
+ return DatabaseBlock::newFromTarget( User::newFromId( $params['userid'] ) );
}
- return Block::newFromId( $params['id'] );
+ return DatabaseBlock::newFromId( $params['id'] );
}
/**
// We only check later on whether the block existed to begin with, because maybe the caller
// expects doApiRequestWithToken to throw, in which case the block might not be expected to
// exist to begin with.
- $this->assertInstanceOf( Block::class, $originalBlock, 'Block should initially exist' );
+ $this->assertInstanceOf( DatabaseBlock::class, $originalBlock, 'Block should initially exist' );
$this->assertNull( $this->getBlockFromParams( $params ), 'Block should have been removed' );
}
public function testUnblockWhenBlocked() {
$this->setExpectedApiException( 'ipbblocked' );
- $block = new Block( [
+ $block = new DatabaseBlock( [
'address' => $this->blocker->getName(),
'by' => $this->getTestUser( 'sysop' )->getUser()->getId(),
] );
}
public function testUnblockSelfWhenBlocked() {
- $block = new Block( [
+ $block = new DatabaseBlock( [
'address' => $this->blocker->getName(),
'by' => $this->getTestUser( 'sysop' )->getUser()->getId(),
] );
$this->doUnblock( [ 'user' => $this->blocker->getName() ] );
}
- // XXX These three tests copy-pasted from ApiBlockTest.php
- public function testUnblockWithTag() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_WRITE_BOTH );
- ChangeTags::defineTag( 'custom tag' );
-
- $this->doUnblock( [ 'tags' => 'custom tag' ] );
-
- $dbw = wfGetDB( DB_MASTER );
- $this->assertSame( 1, (int)$dbw->selectField(
- [ 'change_tag', 'logging' ],
- 'COUNT(*)',
- [ 'log_type' => 'block', 'ct_tag' => 'custom tag' ],
- __METHOD__,
- [],
- [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ] ]
- ) );
- }
-
public function testUnblockWithTagNewBackend() {
- $this->setMwGlobals( 'wgChangeTagsSchemaMigrationStage', MIGRATION_NEW );
ChangeTags::defineTag( 'custom tag' );
$this->doUnblock( [ 'tags' => 'custom tag' ] );
__METHOD__,
[],
[
- 'change_tag' => [ 'INNER JOIN', 'ct_log_id = log_id' ],
- 'change_tag_def' => [ 'INNER JOIN', 'ctd_id = ct_tag_id' ],
+ 'change_tag' => [ 'JOIN', 'ct_log_id = log_id' ],
+ 'change_tag_def' => [ 'JOIN', 'ctd_id = ct_tag_id' ],
]
) );
}