diff options
author | Amir Sarabadani <ladsgroup@gmail.com> | 2023-07-14 14:48:42 +0200 |
---|---|---|
committer | Amir Sarabadani <ladsgroup@gmail.com> | 2023-07-14 14:48:42 +0200 |
commit | 614cd4150761fd804c256e52a285169c002e558d (patch) | |
tree | c226ff0931ee6bbf6348fbbe4b4ffe90533aef49 /tests/phpunit | |
parent | bffa95de81d5dbf7d6e6504d6338f8dbe2d036b7 (diff) | |
download | mediawikicore-614cd4150761fd804c256e52a285169c002e558d.tar.gz mediawikicore-614cd4150761fd804c256e52a285169c002e558d.zip |
tests: Migrate Database::delete calls to DeleteQueryBuilder
Bug: T340065
Change-Id: I92e85efd5d23d100a5df38aedb8edaecc5cbfc65
Diffstat (limited to 'tests/phpunit')
6 files changed, 30 insertions, 15 deletions
diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php b/tests/phpunit/includes/api/ApiEditPageTest.php index bf9cf00e5864..3cb94a3ac712 100644 --- a/tests/phpunit/includes/api/ApiEditPageTest.php +++ b/tests/phpunit/includes/api/ApiEditPageTest.php @@ -888,7 +888,10 @@ class ApiEditPageTest extends ApiTestCase { // Make the middle revision disappear $dbw = wfGetDB( DB_PRIMARY ); - $dbw->delete( 'revision', [ 'rev_id' => $revId2 ], __METHOD__ ); + $dbw->newDeleteQueryBuilder() + ->delete( 'revision' ) + ->where( [ 'rev_id' => $revId2 ] ) + ->caller( __METHOD__ )->execute(); $dbw->update( 'revision', [ 'rev_parent_id' => $revId1 ], [ 'rev_id' => $revId3 ], __METHOD__ ); diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php index 049e9225cf36..042458d4b5bc 100644 --- a/tests/phpunit/includes/changetags/ChangeTagsTest.php +++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php @@ -2,6 +2,7 @@ use MediaWiki\Language\RawMessage; use MediaWiki\MainConfigNames; +use Wikimedia\Rdbms\Platform\ISQLPlatform; /** * @covers ChangeTags @@ -30,8 +31,14 @@ class ChangeTagsTest extends MediaWikiIntegrationTestCase { private function emptyChangeTagsTables() { $dbw = wfGetDB( DB_PRIMARY ); - $dbw->delete( 'change_tag', '*' ); - $dbw->delete( 'change_tag_def', '*' ); + $dbw->newDeleteQueryBuilder() + ->delete( 'change_tag' ) + ->where( ISQLPlatform::ALL_ROWS ) + ->execute(); + $dbw->newDeleteQueryBuilder() + ->delete( 'change_tag_def' ) + ->where( ISQLPlatform::ALL_ROWS ) + ->execute(); } // TODO most methods are not tested diff --git a/tests/phpunit/includes/filerepo/file/LocalFileTest.php b/tests/phpunit/includes/filerepo/file/LocalFileTest.php index 7b9a8985be9e..1e5348c4f393 100644 --- a/tests/phpunit/includes/filerepo/file/LocalFileTest.php +++ b/tests/phpunit/includes/filerepo/file/LocalFileTest.php @@ -650,7 +650,10 @@ class LocalFileTest extends MediaWikiIntegrationTestCase { $this->assertTrue( $user->equals( $file->getUploader() ) ); // Make sure we were actually hitting the WAN cache - $dbw->delete( 'image', [ 'img_name' => 'Random-11m.png' ], __METHOD__ ); + $dbw->newDeleteQueryBuilder() + ->delete( 'image' ) + ->where( [ 'img_name' => 'Random-11m.png' ] ) + ->caller( __METHOD__ )->execute(); $file->invalidateCache(); $file = LocalFile::newFromTitle( $title, $repo ); $this->assertSame( false, $file->exists() ); diff --git a/tests/phpunit/includes/interwiki/InterwikiTest.php b/tests/phpunit/includes/interwiki/InterwikiTest.php index 41bbb079483f..916b3eafd791 100644 --- a/tests/phpunit/includes/interwiki/InterwikiTest.php +++ b/tests/phpunit/includes/interwiki/InterwikiTest.php @@ -1,6 +1,7 @@ <?php use MediaWiki\MainConfigNames; +use Wikimedia\Rdbms\Platform\ISQLPlatform; /** * @covers Interwiki @@ -43,7 +44,10 @@ class InterwikiTest extends MediaWikiIntegrationTestCase { private function populateDB( $iwrows ) { $dbw = wfGetDB( DB_PRIMARY ); - $dbw->delete( 'interwiki', '*', __METHOD__ ); + $dbw->newDeleteQueryBuilder() + ->delete( 'interwiki' ) + ->where( ISQLPlatform::ALL_ROWS ) + ->caller( __METHOD__ )->execute(); $dbw->insert( 'interwiki', array_values( $iwrows ), __METHOD__ ); $this->tablesUsed[] = 'interwiki'; } diff --git a/tests/phpunit/includes/session/BotPasswordSessionProviderTest.php b/tests/phpunit/includes/session/BotPasswordSessionProviderTest.php index 780a006f1d40..246721c8b8a9 100644 --- a/tests/phpunit/includes/session/BotPasswordSessionProviderTest.php +++ b/tests/phpunit/includes/session/BotPasswordSessionProviderTest.php @@ -81,11 +81,10 @@ class BotPasswordSessionProviderTest extends MediaWikiIntegrationTestCase { ->centralIdFromName( $sysop->getName() ); $dbw = wfGetDB( DB_PRIMARY ); - $dbw->delete( - 'bot_passwords', - [ 'bp_user' => $userId, 'bp_app_id' => 'BotPasswordSessionProvider' ], - __METHOD__ - ); + $dbw->newDeleteQueryBuilder() + ->delete( 'bot_passwords' ) + ->where( [ 'bp_user' => $userId, 'bp_app_id' => 'BotPasswordSessionProvider' ] ) + ->caller( __METHOD__ )->execute(); $dbw->insert( 'bot_passwords', [ diff --git a/tests/phpunit/includes/user/BotPasswordTest.php b/tests/phpunit/includes/user/BotPasswordTest.php index f3bc894b3944..db89b9af0b5b 100644 --- a/tests/phpunit/includes/user/BotPasswordTest.php +++ b/tests/phpunit/includes/user/BotPasswordTest.php @@ -63,11 +63,10 @@ class BotPasswordTest extends MediaWikiIntegrationTestCase { $passwordHash = $passwordFactory->newFromPlaintext( 'foobaz' ); $dbw = wfGetDB( DB_PRIMARY ); - $dbw->delete( - 'bot_passwords', - [ 'bp_user' => [ 42, 43 ], 'bp_app_id' => 'BotPassword' ], - __METHOD__ - ); + $dbw->newDeleteQueryBuilder() + ->delete( 'bot_passwords' ) + ->where( [ 'bp_user' => [ 42,43 ], 'bp_app_id' => 'BotPassword' ] ) + ->caller( __METHOD__ )->execute(); $dbw->insert( 'bot_passwords', [ |