From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- tests/phpunit/includes/db/DatabaseSQLTest.php | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'tests/phpunit/includes/db/DatabaseSQLTest.php') diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php b/tests/phpunit/includes/db/DatabaseSQLTest.php index 5c2d4b70..b13751f3 100644 --- a/tests/phpunit/includes/db/DatabaseSQLTest.php +++ b/tests/phpunit/includes/db/DatabaseSQLTest.php @@ -722,4 +722,84 @@ class DatabaseSQLTest extends MediaWikiTestCase { $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' => array( 'value', null, 'value2' ), 'field2' => 'value2' ), + LIST_AND, + "(field IN ('value','value2') OR field IS NULL) AND field2 = 'value2'" + ), + array( + array( 'field' => array( null ), 'field2' => null ), + LIST_AND, + "field IS NULL AND field2 IS NULL" + ), + 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' => array( null, 'value', null, 'value2' ), "field2 != 'value2'" ), + LIST_OR, + "(field IN ('value','value2') OR field IS NULL) OR (field2 != 'value2')" + ), + 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'" + ), + ); + } } -- cgit v1.2.3-54-g00ecf