[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add options and join conds to MediaWikiTestCase::assertSelect

2018-01-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/402376 )

Change subject: Add options and join conds to MediaWikiTestCase::assertSelect
..


Add options and join conds to MediaWikiTestCase::assertSelect

Because selects sometimes need to specify these.

Change-Id: I853e8210bbafe16a62060b9075384afb9cdb03c0
---
M tests/phpunit/MediaWikiTestCase.php
1 file changed, 13 insertions(+), 2 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index d542826..5c27fa1 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -1482,13 +1482,17 @@
 * @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 @@
 
$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;

-- 
To view, visit https://gerrit.wikimedia.org/r/402376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I853e8210bbafe16a62060b9075384afb9cdb03c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie 
Gerrit-Reviewer: Addshore 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add options and join conds to MediaWikiTestCase::assertSelect

2018-01-05 Thread Anomie (Code Review)
Anomie has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402376 )

Change subject: Add options and join conds to MediaWikiTestCase::assertSelect
..

Add options and join conds to MediaWikiTestCase::assertSelect

Because selects sometimes need to specify these.

Change-Id: I853e8210bbafe16a62060b9075384afb9cdb03c0
---
M tests/phpunit/MediaWikiTestCase.php
1 file changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/76/402376/1

diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index d542826..5c27fa1 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -1482,13 +1482,17 @@
 * @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 @@
 
$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;

-- 
To view, visit https://gerrit.wikimedia.org/r/402376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I853e8210bbafe16a62060b9075384afb9cdb03c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits