aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes
diff options
context:
space:
mode:
authorAmir Sarabadani <ladsgroup@gmail.com>2023-08-28 10:52:19 +0200
committerAmir Sarabadani <ladsgroup@gmail.com>2023-09-06 12:30:38 +0200
commit049b34b41ce07e12bb5da574cbfefdbb26e6a2ed (patch)
tree3c7b164461eaf24ed1c524dffbb7aa7bc60188ad /tests/phpunit/includes
parent53858466f1128a9195bd2b3599c2b4a994652105 (diff)
downloadmediawikicore-049b34b41ce07e12bb5da574cbfefdbb26e6a2ed.tar.gz
mediawikicore-049b34b41ce07e12bb5da574cbfefdbb26e6a2ed.zip
Introduce RevisionSelectQueryBuilder
Deprecating RevisionStore::getQueryInfo() and cleaning up a lot of code Also removing a brittle test that wasn't really testing anything. Bug: T344971 Change-Id: Ifd690dc8f030f86e3567a717eaeb830cb6dc703b
Diffstat (limited to 'tests/phpunit/includes')
-rw-r--r--tests/phpunit/includes/import/ImportExportTest.php20
-rw-r--r--tests/phpunit/includes/import/ImportTest.php24
-rw-r--r--tests/phpunit/includes/page/PageArchiveTest.php12
-rw-r--r--tests/phpunit/includes/page/UndeletePageTest.php13
4 files changed, 20 insertions, 49 deletions
diff --git a/tests/phpunit/includes/import/ImportExportTest.php b/tests/phpunit/includes/import/ImportExportTest.php
index 7c264716c566..31b6a07868b8 100644
--- a/tests/phpunit/includes/import/ImportExportTest.php
+++ b/tests/phpunit/includes/import/ImportExportTest.php
@@ -3,6 +3,7 @@
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Tests\Maintenance\DumpAsserter;
use MediaWiki\Title\Title;
+use Wikimedia\Rdbms\SelectQueryBuilder;
/**
* Import/export round trip test.
@@ -122,19 +123,12 @@ class ImportExportTest extends MediaWikiLangTestCase {
*/
private function getRevisions( Title $title ) {
$store = $this->getServiceContainer()->getRevisionStore();
- $qi = $store->getQueryInfo();
-
- $conds = [ 'rev_page' => $title->getArticleID() ];
- $opt = [ 'ORDER BY' => 'rev_id ASC' ];
-
- $rows = $this->db->select(
- $qi['tables'],
- $qi['fields'],
- $conds,
- __METHOD__,
- $opt,
- $qi['joins']
- );
+ $queryBuilder = $store->newSelectQueryBuilder( $this->db )
+ ->joinComment()
+ ->where( [ 'rev_page' => $title->getArticleID() ] )
+ ->orderBy( 'rev_id', SelectQueryBuilder::SORT_ASC );
+
+ $rows = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
$status = $store->newRevisionsFromBatch( $rows );
return $status->getValue();
diff --git a/tests/phpunit/includes/import/ImportTest.php b/tests/phpunit/includes/import/ImportTest.php
index 562ee04a6001..8841e44ff581 100644
--- a/tests/phpunit/includes/import/ImportTest.php
+++ b/tests/phpunit/includes/import/ImportTest.php
@@ -285,30 +285,18 @@ EOF
$importer->doImport();
$db = wfGetDB( DB_PRIMARY );
- $revQuery = $services->getRevisionStore()->getQueryInfo();
-
- $row = $db->selectRow(
- $revQuery['tables'],
- $revQuery['fields'],
- [ 'rev_timestamp' => $db->timestamp( "201601010{$n}0000" ) ],
- __METHOD__,
- [],
- $revQuery['joins']
- );
+ $row = $services->getRevisionStore()->newSelectQueryBuilder( $db )
+ ->where( [ 'rev_timestamp' => $db->timestamp( "201601010{$n}0000" ) ] )
+ ->caller( __METHOD__ )->fetchRow();
$this->assertSame(
$assign && $create ? 'UserDoesNotExist' : 'Xxx>UserDoesNotExist',
$row->rev_user_text
);
$this->assertSame( $assign && $create ? $hookId : 0, (int)$row->rev_user );
- $row = $db->selectRow(
- $revQuery['tables'],
- $revQuery['fields'],
- [ 'rev_timestamp' => $db->timestamp( "201601010{$n}0001" ) ],
- __METHOD__,
- [],
- $revQuery['joins']
- );
+ $row = $services->getRevisionStore()->newSelectQueryBuilder( $db )
+ ->where( [ 'rev_timestamp' => $db->timestamp( "201601010{$n}0001" ) ] )
+ ->caller( __METHOD__ )->fetchRow();
$this->assertSame( ( $assign ? '' : 'Xxx>' ) . $user->getName(), $row->rev_user_text );
$this->assertSame( $assign ? $user->getId() : 0, (int)$row->rev_user );
}
diff --git a/tests/phpunit/includes/page/PageArchiveTest.php b/tests/phpunit/includes/page/PageArchiveTest.php
index 768fe34f80ed..d785edd7d53c 100644
--- a/tests/phpunit/includes/page/PageArchiveTest.php
+++ b/tests/phpunit/includes/page/PageArchiveTest.php
@@ -145,15 +145,9 @@ class PageArchiveTest extends MediaWikiIntegrationTestCase {
$archive->undeleteAsUser( [], $this->getTestSysop()->getUser() );
// Should be back in revision
- $revQuery = $revisionStore->getQueryInfo();
- $row = $dbr->selectRow(
- $revQuery['tables'],
- $revQuery['fields'],
- [ 'rev_id' => $this->ipRev->getId() ],
- __METHOD__,
- [],
- $revQuery['joins']
- );
+ $row = $revisionStore->newSelectQueryBuilder( $dbr )
+ ->where( [ 'rev_id' => $this->ipRev->getId() ] )
+ ->caller( __METHOD__ )->fetchRow();
$this->assertNotFalse( $row, 'row exists in revision table' );
$this->assertEquals( $this->ipEditor, $row->rev_user_text );
diff --git a/tests/phpunit/includes/page/UndeletePageTest.php b/tests/phpunit/includes/page/UndeletePageTest.php
index bec657e2093f..0aa1c81d7a3b 100644
--- a/tests/phpunit/includes/page/UndeletePageTest.php
+++ b/tests/phpunit/includes/page/UndeletePageTest.php
@@ -124,17 +124,12 @@ class UndeletePageTest extends MediaWikiIntegrationTestCase {
$status = $undeletePage->setUndeleteAssociatedTalk( true )->undeleteUnsafe( '' );
$this->assertEquals( 2, $status->value[UndeletePage::REVISIONS_RESTORED] );
- $revQuery = $revisionStore->getQueryInfo();
// check subject page and talk page are both back in the revision table
foreach ( [ 0, 1 ] as $key ) {
- $row = $dbr->selectRow(
- $revQuery['tables'],
- $revQuery['fields'],
- [ 'rev_id' => $this->pages[$key]['revId'] ],
- __METHOD__,
- [],
- $revQuery['joins']
- );
+ $row = $revisionStore->newSelectQueryBuilder( $dbr )
+ ->where( [ 'rev_id' => $this->pages[$key]['revId'] ] )
+ ->caller( __METHOD__ )->fetchRow();
+
$this->assertNotFalse( $row, 'row exists in revision table' );
$this->assertEquals( $this->ipEditor, $row->rev_user_text );