Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/182105

Change subject: Add SQL tests for Database::makeList
......................................................................

Add SQL tests for Database::makeList

Change-Id: I5a5be6769c7d0e5f2a97d3fbefd62df3c59f0716
---
M tests/phpunit/includes/db/DatabaseSQLTest.php
1 file changed, 65 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/182105/1

diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php 
b/tests/phpunit/includes/db/DatabaseSQLTest.php
index 5c2d4b7..9d4765d 100644
--- a/tests/phpunit/includes/db/DatabaseSQLTest.php
+++ b/tests/phpunit/includes/db/DatabaseSQLTest.php
@@ -722,4 +722,69 @@
                        $this->database->dropTable( 'non_existing', __METHOD__ )
                );
        }
+
+       /**
+        * @dataProvider provideMakeList
+        * @covers DatabaseBase::makeList
+        */
+       public function testMakeList( $list, $mode, $sqlText ) {
+               $this->assertEquals( trim( $this->database->makeList(
+                       $list, $mode
+               ) ), $sqlText );
+       }
+
+       public static function provideMakeList() {
+               return array(
+                       array(
+                               array( 'value', 'value2' ),
+                               LIST_COMMA,
+                               "'value','value2'"
+                       ),
+                       array(
+                               array( 'field', 'field2' ),
+                               LIST_NAMES,
+                               "field,field2"
+                       ),
+                       array(
+                               array( 'field' => 'value', 'field2' => 'value2' 
),
+                               LIST_AND,
+                               "field = 'value' AND field2 = 'value2'"
+                       ),
+                       array(
+                               array( 'field' => null, "field2 != 'value2'" ),
+                               LIST_AND,
+                               "field IS NULL AND (field2 != 'value2')"
+                       ),
+                       array(
+                               array( 'field' => 'value', 'field2' => 'value2' 
),
+                               LIST_OR,
+                               "field = 'value' OR field2 = 'value2'"
+                       ),
+                       array(
+                               array( 'field' => 'value', 'field2' => null ),
+                               LIST_OR,
+                               "field = 'value' OR field2 IS NULL"
+                       ),
+                       array(
+                               array( 'field' => array( 'value', 'value2' ), 
'field2' => array( 'value' ) ),
+                               LIST_OR,
+                               "field IN ('value','value2')  OR field2 = 
'value'"
+                       ),
+                       array(
+                               array( 'field' => 'value', 'field2' => 'value2' 
),
+                               LIST_SET,
+                               "field = 'value',field2 = 'value2'"
+                       ),
+                       array(
+                               array( 'field' => 'value', 'field2' => null ),
+                               LIST_SET,
+                               "field = 'value',field2 = NULL"
+                       ),
+                       array(
+                               array( 'field' => 'value', "field2 != 'value2'" 
),
+                               LIST_SET,
+                               "field = 'value',field2 != 'value2'"
+                       ),
+               );
+       }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a5be6769c7d0e5f2a97d3fbefd62df3c59f0716
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

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

Reply via email to