Added tests for issue #1100

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4811 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-07 04:56:17 +00:00
parent 784ee985b5
commit 5e2d4167e3

View file

@ -1001,6 +1001,25 @@ class DboSourceTest extends UnitTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testQuotesInStringConditions() {
$result = $this->db->conditions('Member.email = \'mariano@cricava.com\'');
$expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\'';
$this->assertEqual($result, $expected);
$result = $this->db->conditions('Member.email = "mariano@cricava.com"');
$expected = ' WHERE `Member`.`email` = "mariano@cricava.com"';
$this->assertEqual($result, $expected);
$result = $this->db->conditions('Member.email = \'mariano@cricava.com\' AND Member.user LIKE \'mariano.iglesias%\'');
$expected = ' WHERE `Member`.`email` = \'mariano@cricava.com\' AND `Member`.`user` LIKE \'mariano.iglesias%\'';
$this->assertEqual($result, $expected);
$result = $this->db->conditions('Member.email = "mariano@cricava.com" AND Member.user LIKE "mariano.iglesias%"');
$expected = ' WHERE `Member`.`email` = "mariano@cricava.com" AND `Member`.`user` LIKE "mariano.iglesias%"';
$this->assertEqual($result, $expected);
}
function testArrayConditionsParsing() { function testArrayConditionsParsing() {
$result = $this->db->conditions(array('Candy.name' => 'LIKE a', 'HardCandy.name' => 'LIKE c')); $result = $this->db->conditions(array('Candy.name' => 'LIKE a', 'HardCandy.name' => 'LIKE c'));
$this->assertPattern("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result); $this->assertPattern("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result);