aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/ApiMoveTest.php
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2025-02-07 09:42:31 +1100
committerTim Starling <tstarling@wikimedia.org>2025-03-04 09:12:16 +1100
commitc2f4d23ffe704bcfb9bab7b379cfdaa38232c653 (patch)
treef4b1c22288dc107a0b3331a4f0d1fdc16fe12a9c /tests/phpunit/includes/api/ApiMoveTest.php
parentf141346a30b421370b5d7ff0202e41b59c5eadbe (diff)
downloadmediawikicore-c2f4d23ffe704bcfb9bab7b379cfdaa38232c653.tar.gz
mediawikicore-c2f4d23ffe704bcfb9bab7b379cfdaa38232c653.zip
block: DatabaseBlock constructor caller migration
There's about 100 callers of the DatabaseBlock constructor in core tests, most of them passing an address parameter which needs access to the global service container to parse. Many are passing the constructed object straight to DatabaseBlockStore::insertBlock(). So add insertWithParams() for their convenience, which has some handy shortcut parameters, has service access, and throws on failure. The calling code tends to be shorter than before. For unit tests trying to construct DatabaseBlock objects without a service container, direct construction of BlockTarget subclasses is warranted. Add a default to the $wikiId parameters for their convenience. MockBlockManager had its own 'target' parameter, mixed in with block options, carrying its own special idea of a target, which conflicted with DatabaseBlock's new 'target' parameter. Harmonise the parameters and fix the callers. Bug: T382106 Bug: T385966 Change-Id: I78b45a6003b62962211379c36da5587081f90f00
Diffstat (limited to 'tests/phpunit/includes/api/ApiMoveTest.php')
-rw-r--r--tests/phpunit/includes/api/ApiMoveTest.php4
1 files changed, 1 insertions, 3 deletions
diff --git a/tests/phpunit/includes/api/ApiMoveTest.php b/tests/phpunit/includes/api/ApiMoveTest.php
index eb156aa963ae..4f2f90ab14e8 100644
--- a/tests/phpunit/includes/api/ApiMoveTest.php
+++ b/tests/phpunit/includes/api/ApiMoveTest.php
@@ -3,7 +3,6 @@
namespace MediaWiki\Tests\Api;
use MediaWiki\Api\ApiUsageException;
-use MediaWiki\Block\DatabaseBlock;
use MediaWiki\MainConfigNames;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Title\Title;
@@ -200,7 +199,7 @@ class ApiMoveTest extends ApiTestCase {
$this->assertNull( $blockStore->newFromTarget( '127.0.0.1' ) );
$user = $this->getTestSysop()->getUser();
- $block = new DatabaseBlock( [
+ $blockStore->insertBlockWithParams( [
'address' => $user->getName(),
'by' => $user,
'reason' => 'Capriciousness',
@@ -208,7 +207,6 @@ class ApiMoveTest extends ApiTestCase {
'expiry' => 'infinity',
'enableAutoblock' => true,
] );
- $blockStore->insertBlock( $block );
$title = Title::makeTitle( NS_MAIN, 'TestMoveWhileBlocked' );
$title2 = Title::makeTitle( NS_MAIN, 'TestMoveWhileBlocked 2' );