From: Antoine Musso Date: Sat, 28 May 2011 09:03:44 +0000 (+0000) Subject: * Fix db->makeList() spacing X-Git-Tag: 1.31.0-rc.0~29901 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=716d85ad7e60f0d164c65e1f8423b1227d6012b7;p=lhc%2Fweb%2Fwiklou.git * Fix db->makeList() spacing * Tests assertions where upside-down (expected <-> value) * Tests did not use LIST_AND Follow up r87992 --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 8dc2a76397..c181a112be 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1484,7 +1484,7 @@ abstract class DatabaseBase implements DatabaseType { $list .= $field . $operator . $this->addQuotes( $value[0] ); } else { $operator = $not ? ' NOT IN ' : ' IN '; - $list .= $field . $operator . " (" . $this->makeList( $value ) . ") "; + $list .= $field . $operator . "(" . $this->makeList( $value ) . ")"; } } elseif ( $value === null ) { if ( $mode == LIST_AND || $mode == LIST_OR ) { diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php index 5fac8dceef..e886fa87c9 100644 --- a/tests/phpunit/includes/db/DatabaseTest.php +++ b/tests/phpunit/includes/db/DatabaseTest.php @@ -92,30 +92,30 @@ class DatabaseTest extends MediaWikiTestCase { function testMakeNotInList() { $this->assertEquals( + "field IN ('0','1')", $this->db->makeList( array( 'field' => array( 0, 1 ) - ) ), - "field IN ('0','1')" + ), LIST_AND ) ); $this->assertEquals( + "field NOT IN ('0','1')", $this->db->makeList( array( 'field!' => array( 0, 1 ) - ) ), - "field NOT IN ('0','1')" + ), LIST_AND ) ); // make sure an array with only one value use = or != $this->assertEquals( + "field = '777'", $this->db->makeList( array( 'field' => array( 777 ) - ) ), - "field = 777" + ), LIST_AND ) ); $this->assertEquals( + "field != '888'", $this->db->makeList( array( 'field!' => array( 888 ) - ) ), - "field != 888" + ), LIST_AND ) ); } }