aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWandji69 <collinschuwa@gmail.com>2024-06-13 17:53:25 +0100
committerWandji69 <collinschuwa@gmail.com>2024-06-23 23:47:56 +0100
commitc257e2276c8bbd57c85a516722eb047b3af2ebb9 (patch)
treebfa24e0f5f4d522744616c9c61979e00d96ac429
parented919c186be3598edf7df9f0adfe971f76f88908 (diff)
downloadmediawikicore-c257e2276c8bbd57c85a516722eb047b3af2ebb9.tar.gz
mediawikicore-c257e2276c8bbd57c85a516722eb047b3af2ebb9.zip
Replace db with getDb for Tests
Bug: T316841 Change-Id: I29e535e8ee9b5641a4546d53b98cd5060d39681d
-rw-r--r--tests/phpunit/includes/CommentStore/CommentStoreTest.php8
-rw-r--r--tests/phpunit/includes/Storage/PageUpdaterTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiBlockTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiComparePagesTest.php4
-rw-r--r--tests/phpunit/includes/api/ApiParseTest.php2
-rw-r--r--tests/phpunit/includes/api/ApiStashEditTest.php4
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBlocksTest.php2
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryImageInfoTest.php26
-rw-r--r--tests/phpunit/includes/block/BlockRestrictionStoreTest.php2
-rw-r--r--tests/phpunit/includes/block/DatabaseBlockTest.php6
-rw-r--r--tests/phpunit/includes/cache/BacklinkCacheTest.php4
-rw-r--r--tests/phpunit/includes/changetags/ChangeTagsTest.php18
-rw-r--r--tests/phpunit/includes/db/LoadBalancerTest.php2
-rw-r--r--tests/phpunit/includes/deferred/LinksDeletionUpdateTest.php4
-rw-r--r--tests/phpunit/includes/deferred/LinksUpdateTest.php8
-rw-r--r--tests/phpunit/includes/export/ExportTest.php2
-rw-r--r--tests/phpunit/includes/filerepo/AuthenticatedFileEntryPointTest.php2
-rw-r--r--tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php2
-rw-r--r--tests/phpunit/includes/filerepo/file/LocalFileTest.php14
-rw-r--r--tests/phpunit/includes/import/ImportExportTest.php4
-rw-r--r--tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php2
-rw-r--r--tests/phpunit/includes/jobqueue/jobs/RefreshLinksJobTest.php8
-rw-r--r--tests/phpunit/includes/language/MessageCacheTest.php2
-rw-r--r--tests/phpunit/includes/page/MovePageTest.php2
-rw-r--r--tests/phpunit/includes/page/PageArchiveTest.php6
-rw-r--r--tests/phpunit/includes/page/PageStoreTest.php4
-rw-r--r--tests/phpunit/includes/page/WikiPageDbTest.php8
-rw-r--r--tests/phpunit/includes/search/SearchEngineTest.php4
-rw-r--r--tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php6
-rw-r--r--tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php4
-rw-r--r--tests/phpunit/includes/specials/SpecialBlockTest.php2
-rw-r--r--tests/phpunit/includes/specials/pagers/BlockListPagerTest.php8
-rw-r--r--tests/phpunit/includes/title/TitleTest.php2
-rw-r--r--tests/phpunit/includes/user/ActorMigrationTest.php8
-rw-r--r--tests/phpunit/includes/user/TalkPageNotificationManagerTest.php4
-rw-r--r--tests/phpunit/includes/user/UserEditTrackerTest.php6
-rw-r--r--tests/phpunit/includes/user/UserTest.php10
-rw-r--r--tests/phpunit/includes/watchlist/ClearUserWatchlistJobTest.php4
-rw-r--r--tests/phpunit/includes/watchlist/WatchedItemStoreIntegrationTest.php12
-rw-r--r--tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php26
-rw-r--r--tests/phpunit/integration/includes/db/DatabasePostgresTest.php212
-rw-r--r--tests/phpunit/integration/includes/db/DatabaseSqliteTest.php4
-rw-r--r--tests/phpunit/integration/includes/db/DatabaseSqliteUpgradeTest.php4
-rw-r--r--tests/phpunit/integration/includes/libs/rdbms/resultwrapper/ResultWrapperTest.php14
-rw-r--r--tests/phpunit/integration/includes/user/ActorStoreTest.php98
-rw-r--r--tests/phpunit/integration/includes/user/ActorStoreTestBase.php4
46 files changed, 291 insertions, 291 deletions
diff --git a/tests/phpunit/includes/CommentStore/CommentStoreTest.php b/tests/phpunit/includes/CommentStore/CommentStoreTest.php
index 7590829e89e0..73f88bf56f2b 100644
--- a/tests/phpunit/includes/CommentStore/CommentStoreTest.php
+++ b/tests/phpunit/includes/CommentStore/CommentStoreTest.php
@@ -129,7 +129,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
$wstore = $this->makeStore();
- $fields = $wstore->insert( $this->db, $key, $comment, $data );
+ $fields = $wstore->insert( $this->getDb(), $key, $comment, $data );
$this->assertArrayNotHasKey( $key, $fields, "old field" );
$this->assertArrayHasKey( "{$key}_id", $fields, "new field" );
@@ -158,7 +158,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
$this->assertComment(
$expect,
- $rstore->getCommentLegacy( $this->db, $key, $fieldRow ),
+ $rstore->getCommentLegacy( $this->getDb(), $key, $fieldRow ),
"from getFields()"
);
$this->assertComment(
@@ -272,7 +272,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
$truncated = str_repeat( '💣', CommentStore::COMMENT_CHARACTER_LIMIT - 3 ) . '...';
$store = $this->makeStore();
- $fields = $store->insert( $this->db, 'ipb_reason', $comment );
+ $fields = $store->insert( $this->getDb(), 'ipb_reason', $comment );
$stored = $this->getDb()->newSelectQueryBuilder()
->select( 'comment_text' )
->from( 'comment' )
@@ -285,7 +285,7 @@ class CommentStoreTest extends MediaWikiLangTestCase {
$store = $this->makeStore();
$this->expectException( OverflowException::class );
$this->expectExceptionMessage( "Comment data is too long (65611 bytes, maximum is 65535)" );
- $store->insert( $this->db, 'ipb_reason', 'foo', [
+ $store->insert( $this->getDb(), 'ipb_reason', 'foo', [
'long' => str_repeat( '💣', 16400 )
] );
}
diff --git a/tests/phpunit/includes/Storage/PageUpdaterTest.php b/tests/phpunit/includes/Storage/PageUpdaterTest.php
index 7b5a2e4cb339..2272a8e9db62 100644
--- a/tests/phpunit/includes/Storage/PageUpdaterTest.php
+++ b/tests/phpunit/includes/Storage/PageUpdaterTest.php
@@ -305,7 +305,7 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
);
// check site stats - this asserts that derived data updates where run.
- $stats = $this->db->newSelectQueryBuilder()
+ $stats = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'site_stats' )
->where( '1=1' )
diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php
index f13dad09b6aa..3d9b25c793df 100644
--- a/tests/phpunit/includes/api/ApiBlockTest.php
+++ b/tests/phpunit/includes/api/ApiBlockTest.php
@@ -150,7 +150,7 @@ class ApiBlockTest extends ApiTestCase {
new UltimateAuthority( $this->getTestSysop()->getUser() )
);
- $this->assertSame( '1', $this->db->newSelectQueryBuilder()
+ $this->assertSame( '1', $this->getDb()->newSelectQueryBuilder()
->select( 'bl_deleted' )
->from( 'block' )
->where( [ 'bl_id' => $res[0]['block']['id'] ] )
diff --git a/tests/phpunit/includes/api/ApiComparePagesTest.php b/tests/phpunit/includes/api/ApiComparePagesTest.php
index 16813ba4a25a..b1dbd5263c6a 100644
--- a/tests/phpunit/includes/api/ApiComparePagesTest.php
+++ b/tests/phpunit/includes/api/ApiComparePagesTest.php
@@ -63,9 +63,9 @@ class ApiComparePagesTest extends ApiTestCase {
self::$repl['revB4'] => '20040404044404',
];
foreach ( $updateTimestamps as $id => $ts ) {
- $this->db->newUpdateQueryBuilder()
+ $this->getDb()->newUpdateQueryBuilder()
->update( 'revision' )
- ->set( [ 'rev_timestamp' => $this->db->timestamp( $ts ) ] )
+ ->set( [ 'rev_timestamp' => $this->getDb()->timestamp( $ts ) ] )
->where( [ 'rev_id' => $id ] )
->caller( __METHOD__ )
->execute();
diff --git a/tests/phpunit/includes/api/ApiParseTest.php b/tests/phpunit/includes/api/ApiParseTest.php
index 99aaf45a7df0..3199d81d7602 100644
--- a/tests/phpunit/includes/api/ApiParseTest.php
+++ b/tests/phpunit/includes/api/ApiParseTest.php
@@ -309,7 +309,7 @@ class ApiParseTest extends ApiTestCase {
$this->expectApiErrorCode( 'missingcontent-pageid' );
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'revision' )
->where( [ 'rev_id' => $status->getNewRevision()->getId() ] )
->caller( __METHOD__ )
diff --git a/tests/phpunit/includes/api/ApiStashEditTest.php b/tests/phpunit/includes/api/ApiStashEditTest.php
index 688e72339c8b..9c7cbf3006c8 100644
--- a/tests/phpunit/includes/api/ApiStashEditTest.php
+++ b/tests/phpunit/includes/api/ApiStashEditTest.php
@@ -460,11 +460,11 @@ class ApiStashEditTest extends ApiTestCase {
$this->markTestSkipped();
$key = $this->getStashKey();
- $this->db->lock( $key, __METHOD__, 0 );
+ $this->getDb()->lock( $key, __METHOD__, 0 );
try {
$this->doStash( [], null, 'busy' );
} finally {
- $this->db->unlock( $key, __METHOD__ );
+ $this->getDb()->unlock( $key, __METHOD__ );
}
}
}
diff --git a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
index 3fd958628808..8d5c0c220c05 100644
--- a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
@@ -105,7 +105,7 @@ class ApiQueryBlocksTest extends ApiTestCase {
$pageData = $this->insertPage( $title );
$pageId = $pageData['id'];
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'ipblocks_restrictions' )
->row( [
'ir_ipb_id' => $block->getId(),
diff --git a/tests/phpunit/includes/api/query/ApiQueryImageInfoTest.php b/tests/phpunit/includes/api/query/ApiQueryImageInfoTest.php
index 3d4fbe7599c2..f8adf4cbb74c 100644
--- a/tests/phpunit/includes/api/query/ApiQueryImageInfoTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryImageInfoTest.php
@@ -46,8 +46,8 @@ class ApiQueryImageInfoTest extends ApiTestCase {
$actorId = $this->getServiceContainer()
->getActorStore()
- ->acquireActorId( $this->testUser, $this->db );
- $this->db->newInsertQueryBuilder()
+ ->acquireActorId( $this->testUser, $this->getDb() );
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'image' )
->row( [
'img_name' => 'Random-11m.png',
@@ -61,14 +61,14 @@ class ApiQueryImageInfoTest extends ApiTestCase {
'img_minor_mime' => 'png',
'img_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, "'''comment'''" )->id,
+ ->createComment( $this->getDb(), "'''comment'''" )->id,
'img_actor' => $actorId,
- 'img_timestamp' => $this->db->timestamp( self::NEW_IMAGE_TIMESTAMP ),
+ 'img_timestamp' => $this->getDb()->timestamp( self::NEW_IMAGE_TIMESTAMP ),
'img_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru',
] )
->caller( __METHOD__ )
->execute();
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'oldimage' )
->row( [
'oi_name' => 'Random-11m.png',
@@ -83,9 +83,9 @@ class ApiQueryImageInfoTest extends ApiTestCase {
'oi_minor_mime' => 'png',
'oi_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, 'deleted comment' )->id,
+ ->createComment( $this->getDb(), 'deleted comment' )->id,
'oi_actor' => $actorId,
- 'oi_timestamp' => $this->db->timestamp( self::OLD_IMAGE_TIMESTAMP ),
+ 'oi_timestamp' => $this->getDb()->timestamp( self::OLD_IMAGE_TIMESTAMP ),
'oi_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru',
'oi_deleted' => File::DELETED_FILE | File::DELETED_COMMENT | File::DELETED_USER,
] )
@@ -102,9 +102,9 @@ class ApiQueryImageInfoTest extends ApiTestCase {
'oi_minor_mime' => 'png',
'oi_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, '' )->id,
+ ->createComment( $this->getDb(), '' )->id,
'oi_actor' => $actorId,
- 'oi_timestamp' => $this->db->timestamp( self::NO_COMMENT_TIMESTAMP ),
+ 'oi_timestamp' => $this->getDb()->timestamp( self::NO_COMMENT_TIMESTAMP ),
'oi_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru',
'oi_deleted' => 0,
] )
@@ -118,8 +118,8 @@ class ApiQueryImageInfoTest extends ApiTestCase {
->create( null, new FauxRequest() )->getUser();
$tempActorId = $this->getServiceContainer()
->getActorStore()
- ->acquireActorId( $this->tempUser, $this->db );
- $this->db->newInsertQueryBuilder()
+ ->acquireActorId( $this->tempUser, $this->getDb() );
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'image' )
->row( [
'img_name' => self::IMAGE_2_NAME,
@@ -133,9 +133,9 @@ class ApiQueryImageInfoTest extends ApiTestCase {
'img_minor_mime' => 'png',
'img_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, "'''comment'''" )->id,
+ ->createComment( $this->getDb(), "'''comment'''" )->id,
'img_actor' => $tempActorId,
- 'img_timestamp' => $this->db->timestamp( self::IMAGE_2_TIMESTAMP ),
+ 'img_timestamp' => $this->getDb()->timestamp( self::IMAGE_2_TIMESTAMP ),
'img_sha1' => 'aaaaasim0bgdh0jt4vdltuzoh7',
] )
->caller( __METHOD__ )
diff --git a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php
index 79c437cda5de..4524811deb1a 100644
--- a/tests/phpunit/includes/block/BlockRestrictionStoreTest.php
+++ b/tests/phpunit/includes/block/BlockRestrictionStoreTest.php
@@ -540,7 +540,7 @@ class BlockRestrictionStoreTest extends \MediaWikiLangTestCase {
}
protected function insertRestriction( $blockId, $type, $value ) {
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'ipblocks_restrictions' )
->row( [
'ir_ipb_id' => $blockId,
diff --git a/tests/phpunit/includes/block/DatabaseBlockTest.php b/tests/phpunit/includes/block/DatabaseBlockTest.php
index c26e66a96cd1..410217fdbbd5 100644
--- a/tests/phpunit/includes/block/DatabaseBlockTest.php
+++ b/tests/phpunit/includes/block/DatabaseBlockTest.php
@@ -314,7 +314,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
'address' => $username,
'reason' => 'crosswiki block...',
'timestamp' => wfTimestampNow(),
- 'expiry' => $this->db->getInfinity(),
+ 'expiry' => $this->getDb()->getInfinity(),
'createAccount' => true,
'enableAutoblock' => true,
'hideName' => true,
@@ -419,7 +419,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
$blockStore->insertBlock( $block );
$blockQuery = $blockStore->getQueryInfo();
- $row = $this->db->newSelectQueryBuilder()
+ $row = $this->getDb()->newSelectQueryBuilder()
->queryInfo( $blockQuery )
->where( [
'bl_id' => $block->getId(),
@@ -634,7 +634,7 @@ class DatabaseBlockTest extends MediaWikiLangTestCase {
$this->assertFalse( $result );
// Ensure that there are no restrictions where the blockId is 0.
- $count = $this->db->newSelectQueryBuilder()
+ $count = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'ipblocks_restrictions' )
->where( [ 'ir_ipb_id' => 0 ] )
diff --git a/tests/phpunit/includes/cache/BacklinkCacheTest.php b/tests/phpunit/includes/cache/BacklinkCacheTest.php
index a7863fe84cbd..ca474a6662b0 100644
--- a/tests/phpunit/includes/cache/BacklinkCacheTest.php
+++ b/tests/phpunit/includes/cache/BacklinkCacheTest.php
@@ -125,12 +125,12 @@ class BacklinkCacheTest extends MediaWikiIntegrationTestCase {
public function testPartition() {
$targetId = $this->getServiceContainer()->getLinkTargetLookup()->acquireLinkTargetId(
Title::makeTitle( NS_MAIN, 'BLCTest1234' ),
- $this->db
+ $this->getDb()
);
$targetRow = [
'tl_target_id' => $targetId,
];
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'templatelinks' )
->rows( [
[ 'tl_from' => 56890, 'tl_from_namespace' => 0 ] + $targetRow,
diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php
index d5fb6cf2123c..b756c7c1791c 100644
--- a/tests/phpunit/includes/changetags/ChangeTagsTest.php
+++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php
@@ -40,8 +40,8 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
$this->overrideConfigValue( MainConfigNames::UseTagFilter, $useTags );
if (
$avoidReopeningTables &&
- $this->db->getType() === 'mysql' &&
- str_contains( $this->db->getSoftwareLink(), 'MySQL' )
+ $this->getDb()->getType() === 'mysql' &&
+ str_contains( $this->getDb()->getSoftwareLink(), 'MySQL' )
) {
$this->markTestSkipped( 'See T256006' );
}
@@ -619,7 +619,7 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
public function testGetTags( array $tags, $rcId, $revId, $logId ) {
ChangeTags::addTags( $tags, $rcId, $revId, $logId );
- $actualTags = ChangeTags::getTags( $this->db, $rcId, $revId, $logId );
+ $actualTags = ChangeTags::getTags( $this->getDb(), $rcId, $revId, $logId );
$this->assertSame( $tags, $actualTags );
}
@@ -636,9 +636,9 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
$tags3 = [ 'tag 3' ];
$tags2 = array_merge( $tags3, [ 'tag 2' ] );
$tags1 = array_merge( $tags2, [ 'tag 1' ] );
- $this->assertArrayEquals( $tags3, ChangeTags::getTags( $this->db, $rcId, $revId, $logId ) );
- $this->assertArrayEquals( $tags2, ChangeTags::getTags( $this->db, $rcId, $revId ) );
- $this->assertArrayEquals( $tags1, ChangeTags::getTags( $this->db, $rcId ) );
+ $this->assertArrayEquals( $tags3, ChangeTags::getTags( $this->getDb(), $rcId, $revId, $logId ) );
+ $this->assertArrayEquals( $tags2, ChangeTags::getTags( $this->getDb(), $rcId, $revId ) );
+ $this->assertArrayEquals( $tags1, ChangeTags::getTags( $this->getDb(), $rcId ) );
}
public function testGetTagsWithData() {
@@ -649,13 +649,13 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase {
ChangeTags::addTags( [ 'tag 3_1' ], $rcId3, null, null );
ChangeTags::addTags( [ 'tag 3_2' ], $rcId3, null, null, 'data3_2' );
- $data = ChangeTags::getTagsWithData( $this->db, $rcId1 );
+ $data = ChangeTags::getTagsWithData( $this->getDb(), $rcId1 );
$this->assertSame( [ 'tag 1' => 'data1' ], $data );
- $data = ChangeTags::getTagsWithData( $this->db, $rcId2 );
+ $data = ChangeTags::getTagsWithData( $this->getDb(), $rcId2 );
$this->assertSame( [], $data );
- $data = ChangeTags::getTagsWithData( $this->db, $rcId3 );
+ $data = ChangeTags::getTagsWithData( $this->getDb(), $rcId3 );
$this->assertArrayEquals( [ 'tag 3_1' => null, 'tag 3_2' => 'data3_2' ], $data, false, true );
}
diff --git a/tests/phpunit/includes/db/LoadBalancerTest.php b/tests/phpunit/includes/db/LoadBalancerTest.php
index 03391acccaa3..29c6a34d6062 100644
--- a/tests/phpunit/includes/db/LoadBalancerTest.php
+++ b/tests/phpunit/includes/db/LoadBalancerTest.php
@@ -483,7 +483,7 @@ class LoadBalancerTest extends MediaWikiIntegrationTestCase {
$conf = [
'servers' => [ $serverA, $serverB ],
'clusterName' => 'A',
- 'localDomain' => $this->db->getDomainID()
+ 'localDomain' => $this->getDb()->getDomainID()
];
$lb = new LoadBalancer( $conf );
diff --git a/tests/phpunit/includes/deferred/LinksDeletionUpdateTest.php b/tests/phpunit/includes/deferred/LinksDeletionUpdateTest.php
index 335e6ebf1333..fc6869b8ff52 100644
--- a/tests/phpunit/includes/deferred/LinksDeletionUpdateTest.php
+++ b/tests/phpunit/includes/deferred/LinksDeletionUpdateTest.php
@@ -59,7 +59,7 @@ class LinksDeletionUpdateTest extends MediaWikiLangTestCase {
'templatelinks' => 'tl_from',
];
foreach ( $tables as $table => $fromField ) {
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 1 ] )
->from( $table )
->where( [ $fromField => $id ] )
@@ -74,7 +74,7 @@ class LinksDeletionUpdateTest extends MediaWikiLangTestCase {
$linksDeletionUpdate->doUpdate();
foreach ( $tables as $table => $fromField ) {
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 1 ] )
->from( $table )
->where( [ $fromField => $id ] )
diff --git a/tests/phpunit/includes/deferred/LinksUpdateTest.php b/tests/phpunit/includes/deferred/LinksUpdateTest.php
index 05252b68bc1f..d6d008d57d4b 100644
--- a/tests/phpunit/includes/deferred/LinksUpdateTest.php
+++ b/tests/phpunit/includes/deferred/LinksUpdateTest.php
@@ -582,8 +582,8 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
[ 'tl_target_id' ],
[ 'tl_from' => self::$testingPageId ],
[
- [ $linkTargetLookup->acquireLinkTargetId( $target1, $this->db ) ],
- [ $linkTargetLookup->acquireLinkTargetId( $target2, $this->db ) ],
+ [ $linkTargetLookup->acquireLinkTargetId( $target1, $this->getDb() ) ],
+ [ $linkTargetLookup->acquireLinkTargetId( $target2, $this->getDb() ) ],
]
);
@@ -600,8 +600,8 @@ class LinksUpdateTest extends MediaWikiLangTestCase {
[ 'tl_target_id' ],
[ 'tl_from' => self::$testingPageId ],
[
- [ $linkTargetLookup->acquireLinkTargetId( $target2, $this->db ) ],
- [ $linkTargetLookup->acquireLinkTargetId( $target3, $this->db ) ],
+ [ $linkTargetLookup->acquireLinkTargetId( $target2, $this->getDb() ) ],
+ [ $linkTargetLookup->acquireLinkTargetId( $target3, $this->getDb() ) ],
]
);
}
diff --git a/tests/phpunit/includes/export/ExportTest.php b/tests/phpunit/includes/export/ExportTest.php
index f4acf6964504..7f02c2c4e720 100644
--- a/tests/phpunit/includes/export/ExportTest.php
+++ b/tests/phpunit/includes/export/ExportTest.php
@@ -145,7 +145,7 @@ class ExportTest extends MediaWikiLangTestCase {
private function getXmlDumpForPage( PageIdentity $page ): SimpleXMLElement {
$exporter = $this->getServiceContainer()
->getWikiExporterFactory()
- ->getWikiExporter( $this->db, WikiExporter::FULL );
+ ->getWikiExporter( $this->getDb(), WikiExporter::FULL );
$sink = new DumpStringOutput();
$exporter->setOutputSink( $sink );
diff --git a/tests/phpunit/includes/filerepo/AuthenticatedFileEntryPointTest.php b/tests/phpunit/includes/filerepo/AuthenticatedFileEntryPointTest.php
index 7a70c6364402..12145152fc7f 100644
--- a/tests/phpunit/includes/filerepo/AuthenticatedFileEntryPointTest.php
+++ b/tests/phpunit/includes/filerepo/AuthenticatedFileEntryPointTest.php
@@ -51,7 +51,7 @@ class AuthenticatedFileEntryPointTest extends MediaWikiIntegrationTestCase {
$history = $file->getHistory();
$oldFile = $history[0];
- $this->db->newUpdateQueryBuilder()
+ $this->getDb()->newUpdateQueryBuilder()
->table( 'oldimage' )
->set( [ 'oi_deleted' => 1 ] )
->where( [ 'oi_archive_name' => $oldFile->getArchiveName() ] )
diff --git a/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php b/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
index b5b401348b28..6d8edeb5c999 100644
--- a/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
+++ b/tests/phpunit/includes/filerepo/ThumbnailEntryPointTest.php
@@ -52,7 +52,7 @@ class ThumbnailEntryPointTest extends MediaWikiIntegrationTestCase {
$history = $file->getHistory();
$oldFile = $history[0];
- $this->db->newUpdateQueryBuilder()
+ $this->getDb()->newUpdateQueryBuilder()
->table( 'oldimage' )
->set( [ 'oi_deleted' => 1 ] )
->where( [ 'oi_archive_name' => $oldFile->getArchiveName() ] )
diff --git a/tests/phpunit/includes/filerepo/file/LocalFileTest.php b/tests/phpunit/includes/filerepo/file/LocalFileTest.php
index 5841d5df1884..7c0b70697fd9 100644
--- a/tests/phpunit/includes/filerepo/file/LocalFileTest.php
+++ b/tests/phpunit/includes/filerepo/file/LocalFileTest.php
@@ -333,7 +333,7 @@ class LocalFileTest extends MediaWikiIntegrationTestCase {
UserIdentity $uploader,
int $deletedFlags
): OldLocalFile {
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'oldimage' )
->row( [
'oi_name' => 'Random-11m.png',
@@ -348,11 +348,11 @@ class LocalFileTest extends MediaWikiIntegrationTestCase {
'oi_minor_mime' => 'png',
'oi_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, 'comment' )->id,
+ ->createComment( $this->getDb(), 'comment' )->id,
'oi_actor' => $this->getServiceContainer()
->getActorStore()
- ->acquireActorId( $uploader, $this->db ),
- 'oi_timestamp' => $this->db->timestamp( '20201105235242' ),
+ ->acquireActorId( $uploader, $this->getDb() ),
+ 'oi_timestamp' => $this->getDb()->timestamp( '20201105235242' ),
'oi_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru',
'oi_deleted' => $deletedFlags,
] )
@@ -387,13 +387,13 @@ class LocalFileTest extends MediaWikiIntegrationTestCase {
'fa_minor_mime' => 'png',
'fa_description_id' => $this->getServiceContainer()
->getCommentStore()
- ->createComment( $this->db, 'comment' )->id,
+ ->createComment( $this->getDb(), 'comment' )->id,
'fa_actor' => $this->getServiceContainer()
->getActorStore()
- ->acquireActorId( $uploader, $this->db ),
+ ->acquireActorId( $uploader, $this->getDb() ),
'fa_user' => $uploader->getId(),
'fa_user_text' => $uploader->getName(),
- 'fa_timestamp' => $this->db->timestamp( '20201105235242' ),
+ 'fa_timestamp' => $this->getDb()->timestamp( '20201105235242' ),
'fa_sha1' => 'sy02psim0bgdh0jt4vdltuzoh7j80ru',
'fa_deleted' => $deletedFlags,
]
diff --git a/tests/phpunit/includes/import/ImportExportTest.php b/tests/phpunit/includes/import/ImportExportTest.php
index 6297a5211ccf..83068dcd0682 100644
--- a/tests/phpunit/includes/import/ImportExportTest.php
+++ b/tests/phpunit/includes/import/ImportExportTest.php
@@ -34,7 +34,7 @@ class ImportExportTest extends MediaWikiLangTestCase {
private function getExporter( string $schemaVersion ) {
$exporter = $this->getServiceContainer()
->getWikiExporterFactory()
- ->getWikiExporter( $this->db, WikiExporter::FULL );
+ ->getWikiExporter( $this->getDb(), WikiExporter::FULL );
$exporter->setSchemaVersion( $schemaVersion );
return $exporter;
}
@@ -125,7 +125,7 @@ class ImportExportTest extends MediaWikiLangTestCase {
*/
private function getRevisions( Title $title ) {
$store = $this->getServiceContainer()->getRevisionStore();
- $queryBuilder = $store->newSelectQueryBuilder( $this->db )
+ $queryBuilder = $store->newSelectQueryBuilder( $this->getDb() )
->joinComment()
->where( [ 'rev_page' => $title->getArticleID() ] )
->orderBy( 'rev_id', SelectQueryBuilder::SORT_ASC );
diff --git a/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php b/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php
index 4be3d08a6cae..39b461c151cc 100644
--- a/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php
+++ b/tests/phpunit/includes/interwiki/ClassicInterwikiLookupTest.php
@@ -12,7 +12,7 @@ use MediaWiki\WikiMap\WikiMap;
class ClassicInterwikiLookupTest extends MediaWikiIntegrationTestCase {
private function populateDB( $iwrows ) {
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'interwiki' )
->rows( $iwrows )
->caller( __METHOD__ )
diff --git a/tests/phpunit/includes/jobqueue/jobs/RefreshLinksJobTest.php b/tests/phpunit/includes/jobqueue/jobs/RefreshLinksJobTest.php
index cf68ecfb173b..5f376385d4e3 100644
--- a/tests/phpunit/includes/jobqueue/jobs/RefreshLinksJobTest.php
+++ b/tests/phpunit/includes/jobqueue/jobs/RefreshLinksJobTest.php
@@ -110,12 +110,12 @@ class RefreshLinksJobTest extends MediaWikiIntegrationTestCase {
$parserCache = $this->getServiceContainer()->getParserCache();
$parserCache->deleteOptionsKey( $page );
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'pagelinks' )
->where( ISQLPlatform::ALL_ROWS )
->caller( __METHOD__ )
->execute();
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'categorylinks' )
->where( ISQLPlatform::ALL_ROWS )
->caller( __METHOD__ )
@@ -162,12 +162,12 @@ class RefreshLinksJobTest extends MediaWikiIntegrationTestCase {
$parserCache->deleteOptionsKey( $page1 );
$parserCache->deleteOptionsKey( $page2 );
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'pagelinks' )
->where( ISQLPlatform::ALL_ROWS )
->caller( __METHOD__ )
->execute();
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'categorylinks' )
->where( ISQLPlatform::ALL_ROWS )
->caller( __METHOD__ )
diff --git a/tests/phpunit/includes/language/MessageCacheTest.php b/tests/phpunit/includes/language/MessageCacheTest.php
index aca299984aa5..a8d60494c5a8 100644
--- a/tests/phpunit/includes/language/MessageCacheTest.php
+++ b/tests/phpunit/includes/language/MessageCacheTest.php
@@ -153,7 +153,7 @@ class MessageCacheTest extends MediaWikiLangTestCase {
// Screw up the database so MessageCache::loadFromDB() will
// produce the wrong result for reloading Key1
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'page' )
->where( [ 'page_namespace' => NS_MEDIAWIKI, 'page_title' => 'Key1' ] )
->caller( __METHOD__ )
diff --git a/tests/phpunit/includes/page/MovePageTest.php b/tests/phpunit/includes/page/MovePageTest.php
index 574ceb5a49f2..895d0ee9bfe2 100644
--- a/tests/phpunit/includes/page/MovePageTest.php
+++ b/tests/phpunit/includes/page/MovePageTest.php
@@ -548,7 +548,7 @@ class MovePageTest extends MediaWikiIntegrationTestCase {
// do a cross-namespace move
$new = Title::makeTitle( NS_PROJECT, __METHOD__ );
- $obj = $this->newMovePageWithMocks( $old, $new, [ 'db' => $this->db ] );
+ $obj = $this->newMovePageWithMocks( $old, $new, [ 'db' => $this->getDb() ] );
$status = $obj->move( $this->getTestUser()->getUser() );
// sanity checks
diff --git a/tests/phpunit/includes/page/PageArchiveTest.php b/tests/phpunit/includes/page/PageArchiveTest.php
index 11fefe6ca7bf..024538e285a9 100644
--- a/tests/phpunit/includes/page/PageArchiveTest.php
+++ b/tests/phpunit/includes/page/PageArchiveTest.php
@@ -142,11 +142,11 @@ class PageArchiveTest extends MediaWikiIntegrationTestCase {
'ar_user' => null,
'ar_user_text' => $this->ipEditor,
'ar_actor' => (string)$this->getServiceContainer()->getActorNormalization()
- ->acquireActorId( new UserIdentityValue( 0, $this->ipEditor ), $this->db ),
+ ->acquireActorId( new UserIdentityValue( 0, $this->ipEditor ), $this->getDb() ),
'ar_len' => '11',
'ar_deleted' => '0',
'ar_rev_id' => strval( $this->ipRev->getId() ),
- 'ar_timestamp' => $this->db->timestamp( $this->ipRev->getTimestamp() ),
+ 'ar_timestamp' => $this->getDb()->timestamp( $this->ipRev->getTimestamp() ),
'ar_sha1' => '0qdrpxl537ivfnx4gcpnzz0285yxryy',
'ar_page_id' => strval( $this->ipRev->getPageId() ),
'ar_comment_text' => 'just a test',
@@ -166,7 +166,7 @@ class PageArchiveTest extends MediaWikiIntegrationTestCase {
'ar_len' => '7',
'ar_deleted' => '0',
'ar_rev_id' => strval( $this->firstRev->getId() ),
- 'ar_timestamp' => $this->db->timestamp( $this->firstRev->getTimestamp() ),
+ 'ar_timestamp' => $this->getDb()->timestamp( $this->firstRev->getTimestamp() ),
'ar_sha1' => 'pr0s8e18148pxhgjfa0gjrvpy8fiyxc',
'ar_page_id' => strval( $this->firstRev->getPageId() ),
'ar_comment_text' => 'testing',
diff --git a/tests/phpunit/includes/page/PageStoreTest.php b/tests/phpunit/includes/page/PageStoreTest.php
index a327700e51ba..2ba4d15bc1bc 100644
--- a/tests/phpunit/includes/page/PageStoreTest.php
+++ b/tests/phpunit/includes/page/PageStoreTest.php
@@ -131,7 +131,7 @@ class PageStoreTest extends MediaWikiIntegrationTestCase {
* @covers \MediaWiki\Page\PageStore::getPageForLink
*/
public function testGetPageForLink_crossWiki() {
- $wikiId = $this->db->getDomainID(); // pretend sister site
+ $wikiId = $this->getDb()->getDomainID(); // pretend sister site
$nonexistingPage = $this->getNonexistingTestPage();
$pageStore = $this->getPageStore( [], [ 'wikiId' => $wikiId, 'linkCache' => null ] );
@@ -663,7 +663,7 @@ class PageStoreTest extends MediaWikiIntegrationTestCase {
$existingPage = $this->getExistingTestPage();
$pageStore = $this->getPageStore();
- $row = $this->db->newSelectQueryBuilder()
+ $row = $this->getDb()->newSelectQueryBuilder()
->select( $pageStore->getSelectFields() )
->from( 'page' )
->where( [ 'page_id' => $existingPage->getId() ] )
diff --git a/tests/phpunit/includes/page/WikiPageDbTest.php b/tests/phpunit/includes/page/WikiPageDbTest.php
index f9ef7c6be00b..ce4b21f15b6d 100644
--- a/tests/phpunit/includes/page/WikiPageDbTest.php
+++ b/tests/phpunit/includes/page/WikiPageDbTest.php
@@ -391,7 +391,7 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
// as long as no garbage is written to the database.
}
- $row = $this->db->newSelectQueryBuilder()
+ $row = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'page' )
->where( [ 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey() ] )
@@ -1406,7 +1406,7 @@ more stuff
] ] );
// Check the page_random field has been filled
- $pageRandom = $this->db->newSelectQueryBuilder()
+ $pageRandom = $this->getDb()->newSelectQueryBuilder()
->select( 'page_random' )
->from( 'page' )
->where( $condition )
@@ -1414,7 +1414,7 @@ more stuff
$this->assertTrue( (float)$pageRandom < 1 && (float)$pageRandom > 0 );
// Assert the touched timestamp in the DB is roughly when we inserted the page
- $pageTouched = $this->db->newSelectQueryBuilder()
+ $pageTouched = $this->getDb()->newSelectQueryBuilder()
->select( 'page_touched' )
->from( 'page' )
->where( $condition )
@@ -1853,7 +1853,7 @@ more stuff
public function testGetTouched() {
$page = $this->createPage( __METHOD__, 'whatever' );
- $touched = $this->db->newSelectQueryBuilder()
+ $touched = $this->getDb()->newSelectQueryBuilder()
->select( 'page_touched' )
->from( 'page' )
->where( [ 'page_id' => $page->getId() ] )
diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php
index 1977d703d6ac..c6fea3df398a 100644
--- a/tests/phpunit/includes/search/SearchEngineTest.php
+++ b/tests/phpunit/includes/search/SearchEngineTest.php
@@ -24,9 +24,9 @@ class SearchEngineTest extends MediaWikiLangTestCase {
parent::setUp();
// Search tests require MySQL or SQLite with FTS
- $dbType = $this->db->getType();
+ $dbType = $this->getDb()->getType();
$dbSupported = ( $dbType === 'mysql' )
- || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
+ || ( $dbType === 'sqlite' && $this->getDb()->getFulltextSearchModule() == 'FTS3' );
if ( !$dbSupported ) {
$this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
diff --git a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php
index f803e51500e5..4f14f959f38d 100644
--- a/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php
+++ b/tests/phpunit/includes/specialpage/ChangesListSpecialPageTest.php
@@ -254,7 +254,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
$namespaces = $this->getServiceContainer()->getNamespaceInfo()->getSubjectNamespaces();
$this->assertConditions(
[ # expected
- 'rc_namespace IN (' . $this->db->makeList( $namespaces ) . ')',
+ 'rc_namespace IN (' . $this->getDb()->makeList( $namespaces ) . ')',
],
[
'namespace' => 'all-contents',
@@ -282,7 +282,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
sort( $namespaces );
$this->assertConditions(
[ # expected
- 'rc_namespace IN (' . $this->db->makeList( $namespaces ) . ')',
+ 'rc_namespace IN (' . $this->getDb()->makeList( $namespaces ) . ')',
],
[
'namespace' => 'all-contents;1;invalid',
@@ -293,7 +293,7 @@ class ChangesListSpecialPageTest extends AbstractChangesListSpecialPageTestCase
public function testRcHidemyselfFilter() {
$user = $this->getTestUser()->getUser();
- $encName = $this->db->addQuotes( $user->getName() );
+ $encName = $this->getDb()->addQuotes( $user->getName() );
$this->assertConditions(
[ # expected
"actor_name != $encName",
diff --git a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
index 423a42cc1019..054c418949d6 100644
--- a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
+++ b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php
@@ -60,8 +60,8 @@ class QueryAllSpecialPagesTest extends MediaWikiIntegrationTestCase {
// With MySQL, skips special pages reopening a temporary table
// See https://bugs.mysql.com/bug.php?id=10327
if (
- $this->db->getType() === 'mysql' &&
- str_contains( $this->db->getSoftwareLink(), 'MySQL' ) &&
+ $this->getDb()->getType() === 'mysql' &&
+ str_contains( $this->getDb()->getSoftwareLink(), 'MySQL' ) &&
in_array( $page->getName(), $this->reopensTempTable )
) {
$this->markTestSkipped( "SQL query for page {$page->getName()} "
diff --git a/tests/phpunit/includes/specials/SpecialBlockTest.php b/tests/phpunit/includes/specials/SpecialBlockTest.php
index 0271dca42883..93884b25626f 100644
--- a/tests/phpunit/includes/specials/SpecialBlockTest.php
+++ b/tests/phpunit/includes/specials/SpecialBlockTest.php
@@ -395,7 +395,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
$this->assertSame( [], $block->getRestrictions() );
// Ensure that there are no restrictions where the blockId is 0.
- $count = $this->db->newSelectQueryBuilder()
+ $count = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'ipblocks_restrictions' )
->where( [ 'ir_ipb_id' => 0 ] )
diff --git a/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php b/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php
index a302daa75e56..5e48847a3fc9 100644
--- a/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php
+++ b/tests/phpunit/includes/specials/pagers/BlockListPagerTest.php
@@ -280,7 +280,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
'bl_by' => $admin->getId(),
'bl_by_text' => $admin->getName(),
'bl_sitewide' => 1,
- 'bl_timestamp' => $this->db->timestamp( wfTimestamp( TS_MW ) ),
+ 'bl_timestamp' => $this->getDb()->timestamp( wfTimestamp( TS_MW ) ),
'bl_reason_text' => '[[Comment link]]',
'bl_reason_data' => null,
];
@@ -317,7 +317,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
'address' => $target,
'by' => $this->getTestSysop()->getUser(),
'reason' => 'Parce que',
- 'expiry' => $this->db->getInfinity(),
+ 'expiry' => $this->getDb()->getInfinity(),
'sitewide' => false,
] );
$block->setRestrictions( [
@@ -327,7 +327,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
$blockStore->insertBlock( $block );
$pager = $this->getBlockListPager();
- $result = $this->db->newSelectQueryBuilder()
+ $result = $this->getDb()->newSelectQueryBuilder()
->queryInfo( $pager->getQueryInfo() )
->where( [ 'bl_id' => $block->getId() ] )
->caller( __METHOD__ )
@@ -352,7 +352,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
* @coversNothing
*/
public function testOffset() {
- if ( $this->db->getType() === 'postgres' ) {
+ if ( $this->getDb()->getType() === 'postgres' ) {
$this->markTestSkipped( "PostgreSQL fatals when the first part of " .
"the offset parameter has the wrong timestamp format" );
}
diff --git a/tests/phpunit/includes/title/TitleTest.php b/tests/phpunit/includes/title/TitleTest.php
index b4c75f2fcdaf..d18c50e5a9fd 100644
--- a/tests/phpunit/includes/title/TitleTest.php
+++ b/tests/phpunit/includes/title/TitleTest.php
@@ -759,7 +759,7 @@ class TitleTest extends MediaWikiIntegrationTestCase {
*/
public function testNewFromMissingId() {
// Testing return of null for an id that does not exist
- $maxPageId = (int)$this->db->newSelectQueryBuilder()
+ $maxPageId = (int)$this->getDb()->newSelectQueryBuilder()
->select( 'max(page_id)' )
->from( 'page' )
->caller( __METHOD__ )->fetchField();
diff --git a/tests/phpunit/includes/user/ActorMigrationTest.php b/tests/phpunit/includes/user/ActorMigrationTest.php
index e845963d7ec9..d89425732560 100644
--- a/tests/phpunit/includes/user/ActorMigrationTest.php
+++ b/tests/phpunit/includes/user/ActorMigrationTest.php
@@ -454,7 +454,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
}
$id = ++self::$amId;
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( $table )
->row( [ $pk => $id ] + $fields )
->caller( __METHOD__ )
@@ -465,7 +465,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
$r = $this->getMigration( $readStage );
$queryInfo = $r->getJoin( $key );
- $row = $this->db->newSelectQueryBuilder()
+ $row = $this->getDb()->newSelectQueryBuilder()
->queryInfo( $queryInfo )
->from( $table )
->where( [ $pk => $id ] )
@@ -506,14 +506,14 @@ class ActorMigrationTest extends MediaWikiLangTestCase {
$m = $this->getMigration( $stage );
$fields = $m->getInsertValues( $this->db, 'am1_user', $userIdentity );
$id = ++self::$amId;
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'actormigration1' )
->row( [ 'am1_id' => $id ] + $fields )
->caller( __METHOD__ )
->execute();
$qi = $m->getJoin( 'am1_user' );
- $row = $this->db->newSelectQueryBuilder()
+ $row = $this->getDb()->newSelectQueryBuilder()
->queryInfo( $qi )
->from( 'actormigration1' )
->where( [ 'am1_id' => $id ] )
diff --git a/tests/phpunit/includes/user/TalkPageNotificationManagerTest.php b/tests/phpunit/includes/user/TalkPageNotificationManagerTest.php
index 3963d8ea17fb..70aada71125c 100644
--- a/tests/phpunit/includes/user/TalkPageNotificationManagerTest.php
+++ b/tests/phpunit/includes/user/TalkPageNotificationManagerTest.php
@@ -204,7 +204,7 @@ class TalkPageNotificationManagerTest extends MediaWikiIntegrationTestCase {
->where( [ 'user_id' => $user->getId() ] )
->assertFieldValue( $user->getId() );
- $this->db->startAtomic( __METHOD__ ); // let deferred updates queue up
+ $this->getDb()->startAtomic( __METHOD__ ); // let deferred updates queue up
$updateCountBefore = DeferredUpdates::pendingUpdatesCount();
$manager->clearForPageView( $user, $revision );
@@ -214,7 +214,7 @@ class TalkPageNotificationManagerTest extends MediaWikiIntegrationTestCase {
$updateCountAfter = DeferredUpdates::pendingUpdatesCount();
$this->assertGreaterThan( $updateCountBefore, $updateCountAfter, 'An update should have been queued' );
- $this->db->endAtomic( __METHOD__ ); // run deferred updates
+ $this->getDb()->endAtomic( __METHOD__ ); // run deferred updates
$this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' );
// Notification should have been deleted from the DB
diff --git a/tests/phpunit/includes/user/UserEditTrackerTest.php b/tests/phpunit/includes/user/UserEditTrackerTest.php
index f1974ee1160c..e14c93676dec 100644
--- a/tests/phpunit/includes/user/UserEditTrackerTest.php
+++ b/tests/phpunit/includes/user/UserEditTrackerTest.php
@@ -45,7 +45,7 @@ class UserEditTrackerTest extends MediaWikiIntegrationTestCase {
* @param int|null $count
*/
private function setDbEditCount( $user, $count ) {
- $this->db->newUpdateQueryBuilder()
+ $this->getDb()->newUpdateQueryBuilder()
->update( 'user' )
->set( [ 'user_editcount' => $count ] )
->where( [ 'user_id' => $user->getId() ] )
@@ -133,7 +133,7 @@ class UserEditTrackerTest extends MediaWikiIntegrationTestCase {
$editCountStart = $tracker->getUserEditCount( $user );
- $this->db->startAtomic( __METHOD__ ); // let deferred updates queue up
+ $this->getDb()->startAtomic( __METHOD__ ); // let deferred updates queue up
$tracker->incrementUserEditCount( $user );
$this->assertSame(
@@ -149,7 +149,7 @@ class UserEditTrackerTest extends MediaWikiIntegrationTestCase {
'No update queued for anonymous user'
);
- $this->db->endAtomic( __METHOD__ ); // run deferred updates
+ $this->getDb()->endAtomic( __METHOD__ ); // run deferred updates
$this->assertSame(
0,
DeferredUpdates::pendingUpdatesCount(),
diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php
index 74f6cc36de3f..8f7a33df7c24 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -721,7 +721,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
$user->saveSettings();
$this->assertSame(
$user->getName(),
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( 'actor_name' )
->from( 'actor' )
->where( [ 'actor_id' => $user->getActorId() ] )
@@ -730,7 +730,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
);
$ip = '192.168.12.34';
- $this->db->newDeleteQueryBuilder()
+ $this->getDb()->newDeleteQueryBuilder()
->deleteFrom( 'actor' )
->where( [ 'actor_name' => $ip ] )
->caller( __METHOD__ )
@@ -1254,12 +1254,12 @@ class UserTest extends MediaWikiIntegrationTestCase {
case 'actor':
$name = 'TestNewSystemUser ' . TestUserRegistry::getNextId();
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'actor' )
->row( [ 'actor_name' => $name ] )
->caller( __METHOD__ )
->execute();
- $actorId = (int)$this->db->insertId();
+ $actorId = (int)$this->getDb()->insertId();
break;
case 'user':
@@ -1677,7 +1677,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
$user = User::newFromName( $name );
$user->addToDatabase();
- $field = $this->db->newSelectQueryBuilder()
+ $field = $this->getDb()->newSelectQueryBuilder()
->select( 'user_is_temp' )
->from( 'user' )
->where( [ 'user_name' => $name ] )
diff --git a/tests/phpunit/includes/watchlist/ClearUserWatchlistJobTest.php b/tests/phpunit/includes/watchlist/ClearUserWatchlistJobTest.php
index c01457038769..d61edce00df6 100644
--- a/tests/phpunit/includes/watchlist/ClearUserWatchlistJobTest.php
+++ b/tests/phpunit/includes/watchlist/ClearUserWatchlistJobTest.php
@@ -74,7 +74,7 @@ class ClearUserWatchlistJobTest extends MediaWikiIntegrationTestCase {
$watchedItemStore->addWatch( $user, new TitleValue( 0, __METHOD__ . 'has expiry' ), '1 week' );
// Get the IDs of these items.
- $itemIds = $this->db->newSelectQueryBuilder()
+ $itemIds = $this->getDb()->newSelectQueryBuilder()
->select( 'wl_id' )
->from( 'watchlist' )
->where( [ 'wl_user' => $user->getId() ] )
@@ -89,7 +89,7 @@ class ClearUserWatchlistJobTest extends MediaWikiIntegrationTestCase {
$this->runJobs( [ 'complete' => false ], [ 'maxJobs' => 1 ] );
// Confirm that there are now no expiry records.
- $watchedCount = $this->db->newSelectQueryBuilder()
+ $watchedCount = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'watchlist_expiry' )
->where( [ 'we_item' => $itemIds ] )
diff --git a/tests/phpunit/includes/watchlist/WatchedItemStoreIntegrationTest.php b/tests/phpunit/includes/watchlist/WatchedItemStoreIntegrationTest.php
index 28e39d7e5620..f91a8a1362c4 100644
--- a/tests/phpunit/includes/watchlist/WatchedItemStoreIntegrationTest.php
+++ b/tests/phpunit/includes/watchlist/WatchedItemStoreIntegrationTest.php
@@ -418,15 +418,15 @@ class WatchedItemStoreIntegrationTest extends MediaWikiIntegrationTestCase {
// Manually insert some orphaned non-expired rows.
$orphanRows = [
- [ 'we_item' => '100000', 'we_expiry' => $this->db->timestamp( '30300101000000' ) ],
- [ 'we_item' => '100001', 'we_expiry' => $this->db->timestamp( '30300101000000' ) ],
+ [ 'we_item' => '100000', 'we_expiry' => $this->getDb()->timestamp( '30300101000000' ) ],
+ [ 'we_item' => '100001', 'we_expiry' => $this->getDb()->timestamp( '30300101000000' ) ],
];
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'watchlist_expiry' )
->rows( $orphanRows )
->caller( __METHOD__ )
->execute();
- $initialRowCount = $this->db->newSelectQueryBuilder()
+ $initialRowCount = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'watchlist_expiry' )
->caller( __METHOD__ )->fetchRowCount();
@@ -435,7 +435,7 @@ class WatchedItemStoreIntegrationTest extends MediaWikiIntegrationTestCase {
$store->removeExpired( 10, false );
$this->assertSame(
$initialRowCount,
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'watchlist_expiry' )
->caller( __METHOD__ )->fetchRowCount()
@@ -445,7 +445,7 @@ class WatchedItemStoreIntegrationTest extends MediaWikiIntegrationTestCase {
$store->removeExpired( 10, true );
$this->assertSame(
$initialRowCount - 2,
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'watchlist_expiry' )
->caller( __METHOD__ )->fetchRowCount()
diff --git a/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php b/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
index 2e767ae0c1a5..46e26a310b16 100644
--- a/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
+++ b/tests/phpunit/integration/includes/block/DatabaseBlockStoreTest.php
@@ -187,7 +187,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
public function testNewFromID_missing() {
$store = $this->getStore();
$missingBlockId = 9998;
- $dbRow = $this->db->newSelectQueryBuilder()
+ $dbRow = $this->getDb()->newSelectQueryBuilder()
->select( '*' )
->from( 'block' )
->where( [ 'bl_id' => $missingBlockId ] )
@@ -361,7 +361,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
$store = $this->getStore();
$store->insertBlock( $this->getBlock( [ 'target' => $blockTarget ] ) );
[ $start, $end ] = IPUtils::parseRange( $searchTarget );
- $rows = $this->db->newSelectQueryBuilder()
+ $rows = $this->getDb()->newSelectQueryBuilder()
->queryInfo( $store->getQueryInfo() )
->where( $store->getRangeCond( $start, $end ) )
->fetchResultSet();
@@ -621,12 +621,12 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
* @param bool $expected Whether to expect to find any rows
*/
private function assertPurgeWorked( int $blockId, bool $expected ): void {
- $blockRows = (bool)$this->db->newSelectQueryBuilder()
+ $blockRows = (bool)$this->getDb()->newSelectQueryBuilder()
->select( 'bl_id' )
->from( 'block' )
->where( [ 'bl_id' => $blockId ] )
->fetchResultSet()->numRows();
- $blockRestrictionsRows = (bool)$this->db->newSelectQueryBuilder()
+ $blockRestrictionsRows = (bool)$this->getDb()->newSelectQueryBuilder()
->select( 'ir_ipb_id' )
->from( 'ipblocks_restrictions' )
->where( [ 'ir_ipb_id' => $blockId ] )
@@ -687,7 +687,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
$this->sysop = $this->getTestSysop()->getUser();
// Get a comment ID. One was added in addDBDataOnce.
- $commentId = $this->db->newSelectQueryBuilder()
+ $commentId = $this->getDb()->newSelectQueryBuilder()
->select( 'comment_id' )
->from( 'comment' )
->caller( __METHOD__ )
@@ -696,7 +696,7 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
$commonBlockData = [
'bl_by_actor' => $this->sysop->getActorId(),
'bl_reason_id' => $commentId,
- 'bl_timestamp' => $this->db->timestamp( '20000101000000' ),
+ 'bl_timestamp' => $this->getDb()->timestamp( '20000101000000' ),
'bl_anon_only' => 0,
'bl_create_account' => 0,
'bl_deleted' => 0,
@@ -724,32 +724,32 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
];
$targetIds = [];
foreach ( $targetRows as $i => $row ) {
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'block_target' )
->row( $row + [ 'bt_count' => 1 ] )
->execute();
- $targetIds[$i] = $this->db->insertId();
+ $targetIds[$i] = $this->getDb()->insertId();
}
$blockData = [
[
'bl_id' => $this->expiredBlockId,
'bl_target' => $targetIds['1.1.1.1'],
- 'bl_expiry' => $this->db->timestamp( '20010101000000' ),
+ 'bl_expiry' => $this->getDb()->timestamp( '20010101000000' ),
'bl_enable_autoblock' => 0,
'bl_parent_block_id' => 0,
] + $commonBlockData,
[
'bl_id' => $this->unexpiredBlockId,
'bl_target' => $targetIds['sysop'],
- 'bl_expiry' => $this->db->getInfinity(),
+ 'bl_expiry' => $this->getDb()->getInfinity(),
'bl_enable_autoblock' => 1,
'bl_parent_block_id' => 0,
] + $commonBlockData,
[
'bl_id' => $this->autoblockId,
'bl_target' => $targetIds['2.2.2.2'],
- 'bl_expiry' => $this->db->getInfinity(),
+ 'bl_expiry' => $this->getDb()->getInfinity(),
'bl_enable_autoblock' => 0,
'bl_parent_block_id' => $this->unexpiredBlockId,
] + $commonBlockData,
@@ -773,13 +773,13 @@ class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
],
];
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'block' )
->rows( $blockData )
->caller( __METHOD__ )
->execute();
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'ipblocks_restrictions' )
->rows( $restrictionData )
->caller( __METHOD__ )
diff --git a/tests/phpunit/integration/includes/db/DatabasePostgresTest.php b/tests/phpunit/integration/includes/db/DatabasePostgresTest.php
index 93e21aaae966..b1ef224df300 100644
--- a/tests/phpunit/integration/includes/db/DatabasePostgresTest.php
+++ b/tests/phpunit/integration/includes/db/DatabasePostgresTest.php
@@ -19,13 +19,13 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
protected function setUp(): void {
parent::setUp();
- if ( !$this->db instanceof DatabasePostgres ) {
+ if ( !$this->getDb() instanceof DatabasePostgres ) {
$this->markTestSkipped( 'Not PostgreSQL' );
}
}
public function addDBDataOnce() {
- if ( $this->db instanceof DatabasePostgres ) {
+ if ( $this->getDb() instanceof DatabasePostgres ) {
$this->createSourceTable();
$this->createDestTable();
}
@@ -34,56 +34,56 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
private function doTestInsertIgnore() {
$fname = __METHOD__;
$reset = new ScopedCallback( function () use ( $fname ) {
- if ( $this->db->explicitTrxActive() ) {
- $this->db->rollback( $fname );
+ if ( $this->getDb()->explicitTrxActive() ) {
+ $this->getDb()->rollback( $fname );
}
- $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ), $fname );
+ $this->getDb()->query( 'DROP TABLE IF EXISTS ' . $this->getDb()->tableName( 'foo' ), $fname );
} );
- $this->db->query(
- "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER NOT NULL PRIMARY KEY)",
+ $this->getDb()->query(
+ "CREATE TEMPORARY TABLE {$this->getDb()->tableName( 'foo' )} (i INTEGER NOT NULL PRIMARY KEY)",
__METHOD__
);
- $this->db->insert( 'foo', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
+ $this->getDb()->insert( 'foo', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
// Normal INSERT IGNORE
- $this->db->begin( __METHOD__ );
- $this->db->insert(
+ $this->getDb()->begin( __METHOD__ );
+ $this->getDb()->insert(
'foo', [ [ 'i' => 3 ], [ 'i' => 2 ], [ 'i' => 5 ] ], __METHOD__, [ 'IGNORE' ]
);
- $this->assertSame( 2, $this->db->affectedRows() );
+ $this->assertSame( 2, $this->getDb()->affectedRows() );
$this->assertSame(
[ '1', '2', '3', '5' ],
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( 'i' )
->from( 'foo' )
->orderBy( 'i' )
->caller( __METHOD__ )->fetchFieldValues()
);
- $this->db->rollback( __METHOD__ );
+ $this->getDb()->rollback( __METHOD__ );
// INSERT IGNORE doesn't ignore stuff like NOT NULL violations
- $this->db->begin( __METHOD__ );
- $this->db->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
+ $this->getDb()->begin( __METHOD__ );
+ $this->getDb()->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
try {
- $this->db->insert(
+ $this->getDb()->insert(
'foo', [ [ 'i' => 7 ], [ 'i' => null ] ], __METHOD__, [ 'IGNORE' ]
);
- $this->db->endAtomic( __METHOD__ );
+ $this->getDb()->endAtomic( __METHOD__ );
$this->fail( 'Expected exception not thrown' );
} catch ( DBQueryError $e ) {
- $this->assertSame( 0, $this->db->affectedRows() );
- $this->db->cancelAtomic( __METHOD__ );
+ $this->assertSame( 0, $this->getDb()->affectedRows() );
+ $this->getDb()->cancelAtomic( __METHOD__ );
}
$this->assertSame(
[ '1', '2' ],
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( 'i' )
->from( 'foo' )
->orderBy( 'i' )
->caller( __METHOD__ )->fetchFieldValues()
);
- $this->db->rollback( __METHOD__ );
+ $this->getDb()->rollback( __METHOD__ );
}
/**
@@ -91,11 +91,11 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
* @group Broken
*/
public function testInsertIgnoreOld() {
- if ( $this->db->getServerVersion() < 9.5 ) {
+ if ( $this->getDb()->getServerVersion() < 9.5 ) {
$this->doTestInsertIgnore();
} else {
// Hack version to make it take the old code path
- $w = TestingAccessWrapper::newFromObject( $this->db );
+ $w = TestingAccessWrapper::newFromObject( $this->getDb() );
$oldVer = $w->numericVersion;
$w->numericVersion = 9.4;
try {
@@ -111,8 +111,8 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
* @group Broken
*/
public function testInsertIgnoreNew() {
- if ( $this->db->getServerVersion() < 9.5 ) {
- $this->markTestSkipped( 'PostgreSQL version is ' . $this->db->getServerVersion() );
+ if ( $this->getDb()->getServerVersion() < 9.5 ) {
+ $this->markTestSkipped( 'PostgreSQL version is ' . $this->getDb()->getServerVersion() );
}
$this->doTestInsertIgnore();
@@ -121,59 +121,59 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
private function doTestInsertSelectIgnore() {
$fname = __METHOD__;
$reset = new ScopedCallback( function () use ( $fname ) {
- if ( $this->db->explicitTrxActive() ) {
- $this->db->rollback( $fname );
+ if ( $this->getDb()->explicitTrxActive() ) {
+ $this->getDb()->rollback( $fname );
}
- $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'foo' ), $fname );
- $this->db->query( 'DROP TABLE IF EXISTS ' . $this->db->tableName( 'bar' ), $fname );
+ $this->getDb()->query( 'DROP TABLE IF EXISTS ' . $this->getDb()->tableName( 'foo' ), $fname );
+ $this->getDb()->query( 'DROP TABLE IF EXISTS ' . $this->getDb()->tableName( 'bar' ), $fname );
} );
- $this->db->query(
- "CREATE TEMPORARY TABLE {$this->db->tableName( 'foo' )} (i INTEGER)",
+ $this->getDb()->query(
+ "CREATE TEMPORARY TABLE {$this->getDb()->tableName( 'foo' )} (i INTEGER)",
__METHOD__
);
- $this->db->query(
- "CREATE TEMPORARY TABLE {$this->db->tableName( 'bar' )} (i INTEGER NOT NULL PRIMARY KEY)",
+ $this->getDb()->query(
+ "CREATE TEMPORARY TABLE {$this->getDb()->tableName( 'bar' )} (i INTEGER NOT NULL PRIMARY KEY)",
__METHOD__
);
- $this->db->insert( 'bar', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
+ $this->getDb()->insert( 'bar', [ [ 'i' => 1 ], [ 'i' => 2 ] ], __METHOD__ );
// Normal INSERT IGNORE
- $this->db->begin( __METHOD__ );
- $this->db->insert( 'foo', [ [ 'i' => 3 ], [ 'i' => 2 ], [ 'i' => 5 ] ], __METHOD__ );
- $this->db->insertSelect( 'bar', 'foo', [ 'i' => 'i' ], [], __METHOD__, [ 'IGNORE' ] );
- $this->assertSame( 2, $this->db->affectedRows() );
+ $this->getDb()->begin( __METHOD__ );
+ $this->getDb()->insert( 'foo', [ [ 'i' => 3 ], [ 'i' => 2 ], [ 'i' => 5 ] ], __METHOD__ );
+ $this->getDb()->insertSelect( 'bar', 'foo', [ 'i' => 'i' ], [], __METHOD__, [ 'IGNORE' ] );
+ $this->assertSame( 2, $this->getDb()->affectedRows() );
$this->assertSame(
[ '1', '2', '3', '5' ],
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( 'i' )
->from( 'bar' )
->orderBy( 'i' )
->caller( __METHOD__ )->fetchFieldValues()
);
- $this->db->rollback( __METHOD__ );
+ $this->getDb()->rollback( __METHOD__ );
// INSERT IGNORE doesn't ignore stuff like NOT NULL violations
- $this->db->begin( __METHOD__ );
- $this->db->insert( 'foo', [ [ 'i' => 7 ], [ 'i' => null ] ], __METHOD__ );
- $this->db->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
+ $this->getDb()->begin( __METHOD__ );
+ $this->getDb()->insert( 'foo', [ [ 'i' => 7 ], [ 'i' => null ] ], __METHOD__ );
+ $this->getDb()->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
try {
- $this->db->insertSelect( 'bar', 'foo', [ 'i' => 'i' ], [], __METHOD__, [ 'IGNORE' ] );
- $this->db->endAtomic( __METHOD__ );
+ $this->getDb()->insertSelect( 'bar', 'foo', [ 'i' => 'i' ], [], __METHOD__, [ 'IGNORE' ] );
+ $this->getDb()->endAtomic( __METHOD__ );
$this->fail( 'Expected exception not thrown' );
} catch ( DBQueryError $e ) {
- $this->assertSame( 0, $this->db->affectedRows() );
- $this->db->cancelAtomic( __METHOD__ );
+ $this->assertSame( 0, $this->getDb()->affectedRows() );
+ $this->getDb()->cancelAtomic( __METHOD__ );
}
$this->assertSame(
[ '1', '2' ],
- $this->db->newSelectQueryBuilder()
+ $this->getDb()->newSelectQueryBuilder()
->select( 'i' )
->from( 'bar' )
->orderBy( 'i' )
->caller( __METHOD__ )->fetchFieldValues()
);
- $this->db->rollback( __METHOD__ );
+ $this->getDb()->rollback( __METHOD__ );
}
/**
@@ -181,11 +181,11 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
* @group Broken
*/
public function testInsertSelectIgnoreOld() {
- if ( $this->db->getServerVersion() < 9.5 ) {
+ if ( $this->getDb()->getServerVersion() < 9.5 ) {
$this->doTestInsertSelectIgnore();
} else {
// Hack version to make it take the old code path
- $w = TestingAccessWrapper::newFromObject( $this->db );
+ $w = TestingAccessWrapper::newFromObject( $this->getDb() );
$oldVer = $w->numericVersion;
$w->numericVersion = 9.4;
try {
@@ -201,8 +201,8 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
* @group Broken
*/
public function testInsertSelectIgnoreNew() {
- if ( $this->db->getServerVersion() < 9.5 ) {
- $this->markTestSkipped( 'PostgreSQL version is ' . $this->db->getServerVersion() );
+ if ( $this->getDb()->getServerVersion() < 9.5 ) {
+ $this->markTestSkipped( 'PostgreSQL version is ' . $this->getDb()->getServerVersion() );
}
$this->doTestInsertSelectIgnore();
@@ -218,78 +218,78 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
public function testInsertIdAfterInsert() {
$rows = [ [ 'k' => 'Luca', 'v' => mt_rand( 1, 100 ), 't' => time() ] ];
- $this->db->insert( self::DST_TABLE, $rows, __METHOD__ );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->getDb()->insert( self::DST_TABLE, $rows, __METHOD__ );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testInsertIdAfterInsertIgnore() {
$rows = [ [ 'k' => 'Luca', 'v' => mt_rand( 1, 100 ), 't' => time() ] ];
- $this->db->insert( self::DST_TABLE, $rows, __METHOD__, 'IGNORE' );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->getDb()->insert( self::DST_TABLE, $rows, __METHOD__, 'IGNORE' );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->db->insert( self::DST_TABLE, $rows, __METHOD__, 'IGNORE' );
- $this->assertSame( 0, $this->db->affectedRows() );
- $this->assertSame( 0, $this->db->insertId() );
+ $this->getDb()->insert( self::DST_TABLE, $rows, __METHOD__, 'IGNORE' );
+ $this->assertSame( 0, $this->getDb()->affectedRows() );
+ $this->assertSame( 0, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testInsertIdAfterReplace() {
$rows = [ [ 'k' => 'Luca', 'v' => mt_rand( 1, 100 ), 't' => time() ] ];
- $this->db->replace( self::DST_TABLE, 'k', $rows, __METHOD__ );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->getDb()->replace( self::DST_TABLE, 'k', $rows, __METHOD__ );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->db->replace( self::DST_TABLE, 'k', $rows, __METHOD__ );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 2, $this->db->insertId() );
+ $this->getDb()->replace( self::DST_TABLE, 'k', $rows, __METHOD__ );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 2, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 2, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testInsertIdAfterUpsert() {
$rows = [ [ 'k' => 'Luca', 'v' => mt_rand( 1, 100 ), 't' => time() ] ];
$set = [
- 'v = ' . $this->db->buildExcludedValue( 'v' ),
- 't = ' . $this->db->buildExcludedValue( 't' ) . ' + 1'
+ 'v = ' . $this->getDb()->buildExcludedValue( 'v' ),
+ 't = ' . $this->getDb()->buildExcludedValue( 't' ) . ' + 1'
];
- $this->db->upsert( self::DST_TABLE, $rows, 'k', $set, __METHOD__ );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->getDb()->upsert( self::DST_TABLE, $rows, 'k', $set, __METHOD__ );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->db->upsert( self::DST_TABLE, $rows, 'k', $set, __METHOD__ );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->getDb()->upsert( self::DST_TABLE, $rows, 'k', $set, __METHOD__ );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testInsertIdAfterInsertSelect() {
$rows = [ [ 'sk' => 'Luca', 'sv' => mt_rand( 1, 100 ), 'st' => time() ] ];
- $this->db->insert( self::SRC_TABLE, $rows, __METHOD__, 'IGNORE' );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
- $this->assertSame( 1, (int)$this->db->newSelectQueryBuilder()
+ $this->getDb()->insert( self::SRC_TABLE, $rows, __METHOD__, 'IGNORE' );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
+ $this->assertSame( 1, (int)$this->getDb()->newSelectQueryBuilder()
->select( 'sn' )
->from( self::SRC_TABLE )
->where( [ 'sk' => 'Luca' ] )
->fetchField() );
- $this->db->insertSelect(
+ $this->getDb()->insertSelect(
self::DST_TABLE,
self::SRC_TABLE,
[ 'k' => 'sk', 'v' => 'sv', 't' => 'st' ],
@@ -297,25 +297,25 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
__METHOD__,
'IGNORE'
);
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testInsertIdAfterInsertSelectIgnore() {
$rows = [ [ 'sk' => 'Luca', 'sv' => mt_rand( 1, 100 ), 'st' => time() ] ];
- $this->db->insert( self::SRC_TABLE, $rows, __METHOD__, 'IGNORE' );
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
- $this->assertSame( 1, (int)$this->db->newSelectQueryBuilder()
+ $this->getDb()->insert( self::SRC_TABLE, $rows, __METHOD__, 'IGNORE' );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
+ $this->assertSame( 1, (int)$this->getDb()->newSelectQueryBuilder()
->select( 'sn' )
->from( self::SRC_TABLE )
->where( [ 'sk' => 'Luca' ] )
->fetchField() );
- $this->db->insertSelect(
+ $this->getDb()->insertSelect(
self::DST_TABLE,
self::SRC_TABLE,
[ 'k' => 'sk', 'v' => 'sv', 't' => 'st' ],
@@ -323,11 +323,11 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
__METHOD__,
'IGNORE'
);
- $this->assertSame( 1, $this->db->affectedRows() );
- $this->assertSame( 1, $this->db->insertId() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->db->insertSelect(
+ $this->getDb()->insertSelect(
self::DST_TABLE,
self::SRC_TABLE,
[ 'k' => 'sk', 'v' => 'sv', 't' => 'st' ],
@@ -335,11 +335,11 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
__METHOD__,
'IGNORE'
);
- $this->assertSame( 0, $this->db->affectedRows() );
- $this->assertSame( 0, $this->db->insertId() );
+ $this->assertSame( 0, $this->getDb()->affectedRows() );
+ $this->assertSame( 0, $this->getDb()->insertId() );
$this->assertNWhereKEqualsLuca( 1, self::DST_TABLE );
- $this->assertSame( 1, $this->db->affectedRows() );
+ $this->assertSame( 1, $this->getDb()->affectedRows() );
}
public function testFieldAndIndexInfo() {
@@ -378,7 +378,7 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
}
private function assertNWhereKEqualsLuca( $expected, $table ) {
- $this->assertSame( $expected, (int)$this->db->newSelectQueryBuilder()
+ $this->assertSame( $expected, (int)$this->getDb()->newSelectQueryBuilder()
->select( 'n' )
->from( $table )
->where( [ 'k' => 'Luca' ] )
@@ -386,10 +386,10 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
}
private function createSourceTable() {
- $encTable = $this->db->tableName( 'tmp_src_tbl' );
+ $encTable = $this->getDb()->tableName( 'tmp_src_tbl' );
- $this->db->query( "DROP TABLE IF EXISTS $encTable" );
- $this->db->query(
+ $this->getDb()->query( "DROP TABLE IF EXISTS $encTable" );
+ $this->getDb()->query(
"CREATE TEMPORARY TABLE $encTable (" .
"sn serial not null, " .
"sk text unique not null, " .
@@ -401,10 +401,10 @@ class DatabasePostgresTest extends MediaWikiIntegrationTestCase {
}
private function createDestTable() {
- $encTable = $this->db->tableName( 'tmp_dst_tbl' );
+ $encTable = $this->getDb()->tableName( 'tmp_dst_tbl' );
- $this->db->query( "DROP TABLE IF EXISTS $encTable" );
- $this->db->query(
+ $this->getDb()->query( "DROP TABLE IF EXISTS $encTable" );
+ $this->getDb()->query(
"CREATE TEMPORARY TABLE $encTable (" .
"n serial not null, " .
"k text unique not null, " .
diff --git a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php
index 357dd5d73d24..a26c4a77efdb 100644
--- a/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php
+++ b/tests/phpunit/integration/includes/db/DatabaseSqliteTest.php
@@ -32,8 +32,8 @@ class DatabaseSqliteTest extends \MediaWikiIntegrationTestCase {
$this->markTestSkipped( 'No SQLite support detected' );
}
$this->db = $this->newMockDb();
- if ( version_compare( $this->db->getServerVersion(), '3.6.0', '<' ) ) {
- $this->markTestSkipped( "SQLite at least 3.6 required, {$this->db->getServerVersion()} found" );
+ if ( version_compare( $this->getDb()->getServerVersion(), '3.6.0', '<' ) ) {
+ $this->markTestSkipped( "SQLite at least 3.6 required, {$this->getDb()->getServerVersion()} found" );
}
}
diff --git a/tests/phpunit/integration/includes/db/DatabaseSqliteUpgradeTest.php b/tests/phpunit/integration/includes/db/DatabaseSqliteUpgradeTest.php
index aead9383c5a1..f36c2fd35cb5 100644
--- a/tests/phpunit/integration/includes/db/DatabaseSqliteUpgradeTest.php
+++ b/tests/phpunit/integration/includes/db/DatabaseSqliteUpgradeTest.php
@@ -25,8 +25,8 @@ class DatabaseSqliteUpgradeTest extends \MediaWikiIntegrationTestCase {
$this->markTestSkipped( 'No SQLite support detected' );
}
$this->db = $this->newMockDb();
- if ( version_compare( $this->db->getServerVersion(), '3.6.0', '<' ) ) {
- $this->markTestSkipped( "SQLite at least 3.6 required, {$this->db->getServerVersion()} found" );
+ if ( version_compare( $this->getDb()->getServerVersion(), '3.6.0', '<' ) ) {
+ $this->markTestSkipped( "SQLite at least 3.6 required, {$this->getDb()->getServerVersion()} found" );
}
}
diff --git a/tests/phpunit/integration/includes/libs/rdbms/resultwrapper/ResultWrapperTest.php b/tests/phpunit/integration/includes/libs/rdbms/resultwrapper/ResultWrapperTest.php
index 4cb2f0ccb117..5026b90a0729 100644
--- a/tests/phpunit/integration/includes/libs/rdbms/resultwrapper/ResultWrapperTest.php
+++ b/tests/phpunit/integration/includes/libs/rdbms/resultwrapper/ResultWrapperTest.php
@@ -39,7 +39,7 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
}
public function testIteration() {
- $this->db->insert(
+ $this->getDb()->insert(
'ResultWrapperTest', [
[ 'col_a' => '1', 'col_b' => 'a' ],
[ 'col_a' => '2', 'col_b' => 'b' ],
@@ -64,7 +64,7 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
7 => (object)[ 'col_a' => '8', 'col_b' => 'h' ]
];
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 'col_a', 'col_b' ] )
->from( 'ResultWrapperTest' )
->where( '1 = 1' )
@@ -107,7 +107,7 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
}
public function testCurrentNoResults() {
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 'col_a', 'col_b' ] )
->from( 'ResultWrapperTest' )
->where( '1 = 0' )
@@ -116,7 +116,7 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
}
public function testValidNoResults() {
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 'col_a', 'col_b' ] )
->from( 'ResultWrapperTest' )
->where( '1 = 0' )
@@ -125,7 +125,7 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
}
public function testSeekNoResults() {
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 'col_a', 'col_b' ] )
->from( 'ResultWrapperTest' )
->where( '1 = 0' )
@@ -141,11 +141,11 @@ class ResultWrapperTest extends MediaWikiIntegrationTestCase {
/** @dataProvider provideSeekOutOfBounds */
public function testSeekOutOfBounds( $numRows, $seekPos ) {
for ( $i = 0; $i < $numRows; $i++ ) {
- $this->db->insert( 'ResultWrapperTest',
+ $this->getDb()->insert( 'ResultWrapperTest',
[ [ 'col_a' => $i, 'col_b' => $i ] ],
__METHOD__ );
}
- $res = $this->db->newSelectQueryBuilder()
+ $res = $this->getDb()->newSelectQueryBuilder()
->select( [ 'col_a', 'col_b' ] )
->from( 'ResultWrapperTest' )
->where( '1 = 0' )
diff --git a/tests/phpunit/integration/includes/user/ActorStoreTest.php b/tests/phpunit/integration/includes/user/ActorStoreTest.php
index 9093ba555882..021669922d09 100644
--- a/tests/phpunit/integration/includes/user/ActorStoreTest.php
+++ b/tests/phpunit/integration/includes/user/ActorStoreTest.php
@@ -48,13 +48,13 @@ class ActorStoreTest extends ActorStoreTestBase {
* @dataProvider provideGetActorById
*/
public function testGetActorById( $argument, ?UserIdentity $expected ) {
- $actor = $this->getStore()->getActorById( $argument, $this->db );
+ $actor = $this->getStore()->getActorById( $argument, $this->getDb() );
if ( $expected ) {
$this->assertNotNull( $actor );
$this->assertSameActors( $expected, $actor );
// test caching
- $cachedActor = $this->getStore()->getActorById( $argument, $this->db );
+ $cachedActor = $this->getStore()->getActorById( $argument, $this->getDb() );
$this->assertSame( $actor, $cachedActor );
} else {
$this->assertNull( $actor );
@@ -142,15 +142,15 @@ class ActorStoreTest extends ActorStoreTestBase {
*/
public function testSequentialCacheRetrieval( UserIdentity $expected ) {
// ensure UserIdentity is cached
- $actorId = $this->getStore()->findActorId( $expected, $this->db );
+ $actorId = $this->getStore()->findActorId( $expected, $this->getDb() );
- $cachedActorId = $this->getStore()->findActorId( $expected, $this->db );
+ $cachedActorId = $this->getStore()->findActorId( $expected, $this->getDb() );
$this->assertSame( $actorId, $cachedActorId );
- $cachedActorId = $this->getStore()->acquireActorId( $expected, $this->db );
+ $cachedActorId = $this->getStore()->acquireActorId( $expected, $this->getDb() );
$this->assertSame( $actorId, $cachedActorId );
- $cached = $this->getStore()->getActorById( $actorId, $this->db );
+ $cached = $this->getStore()->getActorById( $actorId, $this->getDb() );
$this->assertNotNull( $cached );
$this->assertSameActors( $expected, $cached );
@@ -168,7 +168,7 @@ class ActorStoreTest extends ActorStoreTestBase {
public function testGetActorByIdRealUser() {
$user = $this->getTestUser()->getUser();
- $actor = $this->getStore()->getActorById( $user->getActorId(), $this->db );
+ $actor = $this->getStore()->getActorById( $user->getActorId(), $this->getDb() );
$this->assertSameActors( $user, $actor );
}
@@ -415,7 +415,7 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->executeWithForeignStore(
$wikiId,
function ( ActorStore $store ) use ( $expected, $actor ) {
- $this->assertSame( $expected, $store->findActorId( $actor, $this->db ) );
+ $this->assertSame( $expected, $store->findActorId( $actor, $this->getDb() ) );
if ( $actor instanceof User ) {
$this->assertSame( $expected ?: 0, $actor->getActorId() );
@@ -423,7 +423,7 @@ class ActorStoreTest extends ActorStoreTestBase {
}
);
} else {
- $this->assertSame( $expected, $this->getStore()->findActorId( $actor, $this->db ) );
+ $this->assertSame( $expected, $this->getStore()->findActorId( $actor, $this->getDb() ) );
if ( $actor instanceof User ) {
$this->assertSame( $expected ?: 0, $actor->getActorId() );
@@ -436,7 +436,7 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->expectException( PreconditionException::class );
$this->getStore()->findActorId(
new UserIdentityValue( 0, self::IP, 'acmewiki' ),
- $this->db
+ $this->getDb()
);
}
@@ -483,7 +483,7 @@ class ActorStoreTest extends ActorStoreTestBase {
* @dataProvider provideFindActorIdByName
*/
public function testFindActorIdByName( $name, $expected ) {
- $this->assertSame( $expected, $this->getStore()->findActorIdByName( $name, $this->db ) );
+ $this->assertSame( $expected, $this->getStore()->findActorIdByName( $name, $this->getDb() ) );
}
public static function provideAcquireActorId() {
@@ -503,7 +503,7 @@ class ActorStoreTest extends ActorStoreTestBase {
*/
public function testAcquireActorId( callable $userCallback ) {
$user = $userCallback( $this->getServiceContainer() );
- $actorId = $this->getStore()->acquireActorId( $user, $this->db );
+ $actorId = $this->getStore()->acquireActorId( $user, $this->getDb() );
$this->assertTrue( $actorId > 0 );
if ( $user instanceof User ) {
@@ -546,7 +546,7 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->executeWithForeignStore(
'acmewiki',
function ( ActorStore $store ) use ( $user, $method ) {
- $actorId = $store->$method( $user, $this->db );
+ $actorId = $store->$method( $user, $this->getDb() );
$this->assertTrue( $actorId > 0 );
if ( $user instanceof User ) {
$this->assertSame( $actorId, $user->getActorId() );
@@ -610,25 +610,25 @@ class ActorStoreTest extends ActorStoreTestBase {
// We rely on DB to protect against duplicates when inserting new actor
$this->setNullLogger( 'rdbms' );
$this->expectException( CannotCreateActorException::class );
- $this->getStore()->$method( $actor, $this->db );
+ $this->getStore()->$method( $actor, $this->getDb() );
}
public function testAcquireNowActorId_existing() {
// We rely on DB to protect against duplicates when inserting new actor
$this->setNullLogger( 'rdbms' );
$this->expectException( CannotCreateActorException::class );
- $this->getStore()->createNewActor( new UserIdentityValue( 24, 'TestUser' ), $this->db );
+ $this->getStore()->createNewActor( new UserIdentityValue( 24, 'TestUser' ), $this->getDb() );
}
public function testAcquireActorId_autocreateTempIP() {
$this->enableAutoCreateTempUser();
$this->expectException( CannotCreateActorException::class );
- $this->getStore()->createNewActor( new UserIdentityValue( 0, '127.3.2.1' ), $this->db );
+ $this->getStore()->createNewActor( new UserIdentityValue( 0, '127.3.2.1' ), $this->getDb() );
}
public function testAcquireActorId_autocreateTempIPallowed() {
$this->enableAutoCreateTempUser();
- $actorId = $this->getStoreForImport()->createNewActor( new UserIdentityValue( 0, '127.3.2.1' ), $this->db );
+ $actorId = $this->getStoreForImport()->createNewActor( new UserIdentityValue( 0, '127.3.2.1' ), $this->getDb() );
$this->assertTrue( $actorId > 0 );
}
@@ -651,14 +651,14 @@ class ActorStoreTest extends ActorStoreTestBase {
* @dataProvider provideAcquireActorId_existing
*/
public function testAcquireActorId_existing( UserIdentityValue $actor, int $expected ) {
- $this->assertSame( $expected, $this->getStore()->acquireActorId( $actor, $this->db ) );
+ $this->assertSame( $expected, $this->getStore()->acquireActorId( $actor, $this->getDb() ) );
}
public function testAcquireActorId_domain_mismatch() {
$this->expectException( InvalidArgumentException::class );
$this->getStore( 'fancywiki' )->acquireActorId(
new UserIdentityValue( 15, 'Test', 'fancywiki' ),
- $this->db
+ $this->getDb()
);
}
@@ -666,7 +666,7 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->expectException( InvalidArgumentException::class );
$this->getStore( 'fancywiki' )->createNewActor(
new UserIdentityValue( 15, 'Test', 'fancywiki' ),
- $this->db
+ $this->getDb()
);
}
@@ -674,7 +674,7 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->expectException( InvalidArgumentException::class );
$this->getStore( 'fancywiki' )->acquireSystemActorId(
new UserIdentityValue( 15, 'Test', 'fancywiki' ),
- $this->db
+ $this->getDb()
);
}
@@ -683,36 +683,36 @@ class ActorStoreTest extends ActorStoreTestBase {
$this->expectException( PreconditionException::class );
$this->getStore()->acquireActorId(
new UserIdentityValue( 0, self::IP, 'acmewiki' ),
- $this->db
+ $this->getDb()
);
}
public function testAcquireActorId_clearCacheOnRollback() {
$rolledBackActor = new UserIdentityValue( 0, '127.0.0.10' );
$store = $this->getStore();
- $this->db->startAtomic( __METHOD__ );
- $rolledBackActorId = $store->acquireActorId( $rolledBackActor, $this->db );
+ $this->getDb()->startAtomic( __METHOD__ );
+ $rolledBackActorId = $store->acquireActorId( $rolledBackActor, $this->getDb() );
$this->assertTrue( $rolledBackActorId > 0 );
- $foundActorId = $store->findActorId( $rolledBackActor, $this->db );
+ $foundActorId = $store->findActorId( $rolledBackActor, $this->getDb() );
$this->assertSame( $rolledBackActorId, $foundActorId );
- $this->db->rollback( __METHOD__ );
+ $this->getDb()->rollback( __METHOD__ );
// Insert some other user identity using another store
// so that we take over the rolled back actor ID.
$anotherActor = new UserIdentityValue( 0, '127.0.0.11' );
- $anotherActorId = $this->getStore()->acquireActorId( $anotherActor, $this->db );
+ $anotherActorId = $this->getStore()->acquireActorId( $anotherActor, $this->getDb() );
// Make sure no actor ID associated with rolled back actor.
- $foundActorIdAfterRollback = $store->findActorId( $rolledBackActor, $this->db );
+ $foundActorIdAfterRollback = $store->findActorId( $rolledBackActor, $this->getDb() );
$this->assertNull( $foundActorIdAfterRollback );
// Make sure we can acquire new actor ID for the rolled back actor
- $newActorId = $store->acquireActorId( $rolledBackActor, $this->db );
+ $newActorId = $store->acquireActorId( $rolledBackActor, $this->getDb() );
$this->assertTrue( $newActorId > 0 );
$this->assertNotSame( $newActorId, $rolledBackActorId );
// Make sure we find correct actor by rolled back actor ID
- $this->assertSameActors( $anotherActor, $store->getActorById( $anotherActorId, $this->db ) );
+ $this->assertSameActors( $anotherActor, $store->getActorById( $anotherActorId, $this->getDb() ) );
}
public function testUserRenameUpdatesActor() {
@@ -720,13 +720,13 @@ class ActorStoreTest extends ActorStoreTestBase {
$oldName = $user->getName();
$store = $this->getStore();
- $actorId = $store->findActorId( $user, $this->db );
+ $actorId = $store->findActorId( $user, $this->getDb() );
$this->assertTrue( $actorId > 0 );
$user->setName( 'NewName' );
$user->saveSettings();
- $this->assertSameActors( $user, $store->getActorById( $actorId, $this->db ) );
+ $this->assertSameActors( $user, $store->getActorById( $actorId, $this->getDb() ) );
$this->assertSameActors( $user, $store->getUserIdentityByName( 'NewName' ) );
$this->assertSameActors( $user, $store->getUserIdentityByUserId( $user->getId() ) );
$this->assertNull( $store->getUserIdentityByName( $oldName ) );
@@ -735,14 +735,14 @@ class ActorStoreTest extends ActorStoreTestBase {
public function testAcquireSystemActorId() {
$store = $this->getStore();
$originalActor = new UserIdentityValue( 0, '129.0.0.1' );
- $actorId = $store->createNewActor( $originalActor, $this->db );
+ $actorId = $store->createNewActor( $originalActor, $this->getDb() );
$this->assertTrue( $actorId > 0, 'Acquired new actor ID' );
$updatedActor = new UserIdentityValue( 56789, '129.0.0.1' );
- $this->assertSame( $actorId, $store->acquireSystemActorId( $updatedActor, $this->db ) );
- $this->assertSame( 56789, $store->getActorById( $actorId, $this->db )->getId() );
+ $this->assertSame( $actorId, $store->acquireSystemActorId( $updatedActor, $this->getDb() ) );
+ $this->assertSame( 56789, $store->getActorById( $actorId, $this->getDb() )->getId() );
// Try with another store to verify not just cache was updated
- $this->assertSame( 56789, $this->getStore()->getActorById( $actorId, $this->db )->getId() );
+ $this->assertSame( 56789, $this->getStore()->getActorById( $actorId, $this->getDb() )->getId() );
}
public function testAcquireSystemActorId_replaceReserved() {
@@ -752,42 +752,42 @@ class ActorStoreTest extends ActorStoreTestBase {
);
$store = $this->getStore();
$originalActor = new UserIdentityValue( 0, 'RESERVED' );
- $actorId = $store->createNewActor( $originalActor, $this->db );
+ $actorId = $store->createNewActor( $originalActor, $this->getDb() );
$this->assertTrue( $actorId > 0, 'Acquired new actor ID' );
$updatedActor = new UserIdentityValue( 80, 'RESERVED' );
- $this->assertSame( $actorId, $store->acquireSystemActorId( $updatedActor, $this->db ) );
- $this->assertSame( 80, $store->getActorById( $actorId, $this->db )->getId() );
+ $this->assertSame( $actorId, $store->acquireSystemActorId( $updatedActor, $this->getDb() ) );
+ $this->assertSame( 80, $store->getActorById( $actorId, $this->getDb() )->getId() );
// Try with another store to verify not just cache was updated
- $this->assertSame( 80, $this->getStore()->getActorById( $actorId, $this->db )->getId() );
+ $this->assertSame( 80, $this->getStore()->getActorById( $actorId, $this->getDb() )->getId() );
}
public function testAcquireSystemActorId_assignsNew() {
$store = $this->getStore();
$newActor = new UserIdentityValue( 456789, '129.0.0.2' );
- $newActorId = $store->acquireSystemActorId( $newActor, $this->db );
+ $newActorId = $store->acquireSystemActorId( $newActor, $this->getDb() );
$this->assertTrue( $newActorId > 0 );
- $this->assertSame( 456789, $store->getActorById( $newActorId, $this->db )->getId() );
+ $this->assertSame( 456789, $store->getActorById( $newActorId, $this->getDb() )->getId() );
// Try with another store to verify not just cache was updated
- $this->assertSame( 456789, $this->getStore()->getActorById( $newActorId, $this->db )->getId() );
+ $this->assertSame( 456789, $this->getStore()->getActorById( $newActorId, $this->getDb() )->getId() );
}
public function testDelete() {
$store = $this->getStore();
$actor = new UserIdentityValue( 9999, 'DeleteTest' );
- $actorId = $store->acquireActorId( $actor, $this->db );
- $this->assertTrue( $store->deleteActor( $actor, $this->db ) );
+ $actorId = $store->acquireActorId( $actor, $this->getDb() );
+ $this->assertTrue( $store->deleteActor( $actor, $this->getDb() ) );
- $this->assertNull( $store->findActorId( $actor, $this->db ) );
+ $this->assertNull( $store->findActorId( $actor, $this->getDb() ) );
$this->assertNull( $store->getUserIdentityByUserId( $actor->getId() ) );
$this->assertNull( $store->getUserIdentityByName( $actor->getName() ) );
- $this->assertNull( $store->getActorById( $actorId, $this->db ) );
+ $this->assertNull( $store->getActorById( $actorId, $this->getDb() ) );
}
public function testDeleteDoesNotExist() {
$this->assertFalse(
- $this->getStore()->deleteActor( new UserIdentityValue( 9998, 'DoesNotExist' ), $this->db )
+ $this->getStore()->deleteActor( new UserIdentityValue( 9998, 'DoesNotExist' ), $this->getDb() )
);
}
@@ -827,7 +827,7 @@ class ActorStoreTest extends ActorStoreTestBase {
public function testNewSelectQueryBuilderWithDB() {
$store = $this->getStore();
- $queryBuilder = $store->newSelectQueryBuilder( $this->db );
+ $queryBuilder = $store->newSelectQueryBuilder( $this->getDb() );
$this->assertInstanceOf( UserSelectQueryBuilder::class, $queryBuilder );
}
diff --git a/tests/phpunit/integration/includes/user/ActorStoreTestBase.php b/tests/phpunit/integration/includes/user/ActorStoreTestBase.php
index d79c8943545b..c82cd520deab 100644
--- a/tests/phpunit/integration/includes/user/ActorStoreTestBase.php
+++ b/tests/phpunit/integration/includes/user/ActorStoreTestBase.php
@@ -25,13 +25,13 @@ abstract class ActorStoreTestBase extends MediaWikiIntegrationTestCase {
];
foreach ( $actors as $description => $row ) {
- $this->db->newInsertQueryBuilder()
+ $this->getDb()->newInsertQueryBuilder()
->insertInto( 'actor' )
->ignore()
->row( $row )
->caller( __METHOD__ )
->execute();
- $this->assertSame( 1, $this->db->affectedRows(), "Must create {$description} actor" );
+ $this->assertSame( 1, $this->getDb()->affectedRows(), "Must create {$description} actor" );
}
}