From: Brad Jorsch Date: Fri, 5 Jan 2018 16:26:56 +0000 (-0500) Subject: Add options and join conds to MediaWikiTestCase::assertSelect X-Git-Tag: 1.31.0-rc.0~979^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=1b9f454629a522e7d37fbe1a4cdffbc511c3728d;p=lhc%2Fweb%2Fwiklou.git Add options and join conds to MediaWikiTestCase::assertSelect Because selects sometimes need to specify these. Change-Id: I853e8210bbafe16a62060b9075384afb9cdb03c0 --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index d5428268b5..5c27fa1df9 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1482,13 +1482,17 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @param string|array $fields The columns to include in the result (and to sort by) * @param string|array $condition "where" condition(s) * @param array $expectedRows An array of arrays giving the expected rows. + * @param array $options Options for the query + * @param array $join_conds Join conditions for the query * * @throws MWException If this test cases's needsDB() method doesn't return true. * Test cases can use "@group Database" to enable database test support, * or list the tables under testing in $this->tablesUsed, or override the * needsDB() method. */ - protected function assertSelect( $table, $fields, $condition, array $expectedRows ) { + protected function assertSelect( + $table, $fields, $condition, array $expectedRows, array $options = [], array $join_conds = [] + ) { if ( !$this->needsDB() ) { throw new MWException( 'When testing database state, the test cases\'s needDB()' . ' method should return true. Use @group Database or $this->tablesUsed.' ); @@ -1496,7 +1500,14 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $db = wfGetDB( DB_REPLICA ); - $res = $db->select( $table, $fields, $condition, wfGetCaller(), [ 'ORDER BY' => $fields ] ); + $res = $db->select( + $table, + $fields, + $condition, + wfGetCaller(), + $options + [ 'ORDER BY' => $fields ], + $join_conds + ); $this->assertNotEmpty( $res, "query failed: " . $db->lastError() ); $i = 0;