aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/logging/DatabaseLogEntryTest.php
diff options
context:
space:
mode:
authorDreamy Jazz <wbrown-ctr@wikimedia.org>2023-10-11 00:06:59 +0100
committerDreamy Jazz <dreamyjazzwikipedia@gmail.com>2023-10-11 00:25:45 +0100
commit3d98381fff71882133c9947c878b9351b4447964 (patch)
tree0bc6737cd55766a0713d639de6dc2478edae8ce1 /tests/phpunit/includes/logging/DatabaseLogEntryTest.php
parent4c535f9978778f557006545b84ec04b31a9ff9c7 (diff)
downloadmediawikicore-3d98381fff71882133c9947c878b9351b4447964.tar.gz
mediawikicore-3d98381fff71882133c9947c878b9351b4447964.zip
Use IReadableDatabase over IDatabase in DatabaseLogEntry::newFromId
Why: * The DatabaseLogEntry::newFromId method only uses the provided DB for SELECT queries (via the DatabaseLogEntry ::newSelectQueryBuilder method). * The DatabaseLogEntry::newSelectQueryBuilder method takes a IReadableDatabase object and this is the only usage of the DB provided to ::newFromId * As such, the ::newFromId type should be IReadableDatabase instead of IDatabase so that callers who only have a readable database connection can still use this method. What: * Change the type of the $db parameter of DatabaseLogEntry ::newFromId to be a IReadableDatabase instead of an IDatabase. * Update RCDatabaseLogEntry::newFromId to reflect the change in parameter type. * Update the associated tests to use a IReadableDatabase. Change-Id: Idc6c13b147a5ff99d0969c1120eb1deb2d111496
Diffstat (limited to 'tests/phpunit/includes/logging/DatabaseLogEntryTest.php')
-rw-r--r--tests/phpunit/includes/logging/DatabaseLogEntryTest.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/phpunit/includes/logging/DatabaseLogEntryTest.php b/tests/phpunit/includes/logging/DatabaseLogEntryTest.php
index 28a28b84e9a4..999a00a93164 100644
--- a/tests/phpunit/includes/logging/DatabaseLogEntryTest.php
+++ b/tests/phpunit/includes/logging/DatabaseLogEntryTest.php
@@ -3,7 +3,7 @@
use MediaWiki\User\ActorStore;
use MediaWiki\User\UserIdentity;
use MediaWiki\User\UserIdentityValue;
-use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\IReadableDatabase;
/**
* @group Database
@@ -40,7 +40,7 @@ class DatabaseLogEntryTest extends MediaWikiIntegrationTestCase {
array $expectedFields = null
) {
$row = $row ? (object)$row : null;
- $db = $this->createMock( IDatabase::class );
+ $db = $this->createMock( IReadableDatabase::class );
$db->expects( self::once() )
->method( 'selectRow' )
->with( $selectFields['tables'],
@@ -52,7 +52,7 @@ class DatabaseLogEntryTest extends MediaWikiIntegrationTestCase {
)
->will( self::returnValue( $row ) );
- /** @var IDatabase $db */
+ /** @var IReadableDatabase $db */
$logEntry = DatabaseLogEntry::newFromId( $id, $db );
if ( !$expectedFields ) {