From 6a091dcb39bfd10f1c4a248cc3ff7f95f70066b3 Mon Sep 17 00:00:00 2001 From: Wandji69 Date: Thu, 27 Jun 2024 14:54:32 +0100 Subject: [PATCH] Tests: Repalce "db" with getDb() method Bug: T316841 Change-Id: I40eb000f008e51aba581ee8e33a8421ff111fbf1 --- tests/phpunit/integration/FilterStoreTest.php | 6 +++--- .../integration/Maintenance/PurgeOldLogIPDataTest.php | 11 ++++++----- .../integration/Maintenance/SearchFiltersTest.php | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/integration/FilterStoreTest.php b/tests/phpunit/integration/FilterStoreTest.php index 1a7ae24ff..0810fe894 100644 --- a/tests/phpunit/integration/FilterStoreTest.php +++ b/tests/phpunit/integration/FilterStoreTest.php @@ -42,7 +42,7 @@ class FilterStoreTest extends MediaWikiIntegrationTestCase { */ private function createFilter( int $id ): void { $row = self::DEFAULT_VALUES; - $row['timestamp'] = $this->db->timestamp( $row['timestamp'] ); + $row['timestamp'] = $this->getDb()->timestamp( $row['timestamp'] ); $filter = $this->getFilterFromSpecs( [ 'id' => $id ] + $row ); $oldFilter = MutableFilter::newDefault(); // Use some black magic to bypass checks @@ -51,9 +51,9 @@ class FilterStoreTest extends MediaWikiIntegrationTestCase { $row = $filterStore->filterToDatabaseRow( $filter, $oldFilter ); $row['af_actor'] = $this->getServiceContainer()->getActorNormalization()->acquireActorId( $this->getTestUser()->getUserIdentity(), - $this->db + $this->getDb() ); - $this->db->newInsertQueryBuilder() + $this->getDb()->newInsertQueryBuilder() ->insertInto( 'abuse_filter' ) ->row( $row ) ->caller( __METHOD__ ) diff --git a/tests/phpunit/integration/Maintenance/PurgeOldLogIPDataTest.php b/tests/phpunit/integration/Maintenance/PurgeOldLogIPDataTest.php index 73bfe86f1..8a0c09352 100644 --- a/tests/phpunit/integration/Maintenance/PurgeOldLogIPDataTest.php +++ b/tests/phpunit/integration/Maintenance/PurgeOldLogIPDataTest.php @@ -50,12 +50,13 @@ class PurgeOldLogIPDataTest extends MaintenanceBaseTestCase { ConvertibleTimestamp::convert( TS_UNIX, self::FAKE_TIME ) - 2 * self::MAX_AGE ); $rows = [ - [ 'afl_id' => 1, 'afl_timestamp' => $this->db->timestamp( $oldTS ) ] + $defaultRow, - [ 'afl_id' => 2, 'afl_timestamp' => $this->db->timestamp( $oldTS ), 'afl_ip' => '' ] + $defaultRow, - [ 'afl_id' => 3, 'afl_timestamp' => $this->db->timestamp( self::FAKE_TIME ) ] + $defaultRow, - [ 'afl_id' => 4, 'afl_timestamp' => $this->db->timestamp( self::FAKE_TIME ), 'afl_ip' => '' ] + $defaultRow, + [ 'afl_id' => 1, 'afl_timestamp' => $this->getDb()->timestamp( $oldTS ) ] + $defaultRow, + [ 'afl_id' => 2, 'afl_timestamp' => $this->getDb()->timestamp( $oldTS ), 'afl_ip' => '' ] + $defaultRow, + [ 'afl_id' => 3, 'afl_timestamp' => $this->getDb()->timestamp( self::FAKE_TIME ) ] + $defaultRow, + [ 'afl_id' => 4, 'afl_timestamp' => $this->getDb() + ->timestamp( self::FAKE_TIME ), 'afl_ip' => '' ] + $defaultRow, ]; - $this->db->newInsertQueryBuilder() + $this->getDb()->newInsertQueryBuilder() ->insertInto( 'abuse_filter_log' ) ->rows( $rows ) ->caller( __METHOD__ ) diff --git a/tests/phpunit/integration/Maintenance/SearchFiltersTest.php b/tests/phpunit/integration/Maintenance/SearchFiltersTest.php index 5b8bdb227..6bfca9bb3 100644 --- a/tests/phpunit/integration/Maintenance/SearchFiltersTest.php +++ b/tests/phpunit/integration/Maintenance/SearchFiltersTest.php @@ -38,7 +38,7 @@ class SearchFiltersTest extends MaintenanceBaseTestCase { public function addDBData() { $defaultRow = [ 'af_actor' => 1, - 'af_timestamp' => $this->db->timestamp( '20190826000000' ), + 'af_timestamp' => $this->getDb()->timestamp( '20190826000000' ), 'af_enabled' => 1, 'af_comments' => '', 'af_public_comments' => 'Test filter', @@ -56,7 +56,7 @@ class SearchFiltersTest extends MaintenanceBaseTestCase { [ 'af_id' => 3, 'af_pattern' => 'user_editcount % 3 !== 1' ] + $defaultRow, [ 'af_id' => 4, 'af_pattern' => 'rmspecials(added_lines_pst) !== ""' ] + $defaultRow ]; - $this->db->newInsertQueryBuilder() + $this->getDb()->newInsertQueryBuilder() ->insertInto( 'abuse_filter' ) ->rows( $rows ) ->caller( __METHOD__ )