Adding tests for #2414

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4911 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-29 04:18:41 +00:00
parent 91d4b05e9b
commit 5903e2226c

View file

@ -1285,6 +1285,58 @@ class DboSourceTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
function testParenthesisInStringConditions() {
$result = $this->db->conditions('Member.name = \'Mariano Iglesias (mariano.iglesias)\'');
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result);
$result = $this->db->conditions('Member.name = "Mariano Iglesias (mariano.iglesias)"');
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\"Mariano Iglesias \(mariano.iglesias\)\"$/', $result);
}
function testParenthesisInArrayConditions() {
$result = $this->db->conditions(array('Member.name' => '(lu'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result);
$result = $this->db->conditions(array('Member.name' => ')lu'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'va(lu'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'va)lu'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'va(lu)'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'va(lu)e'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano)'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano)iglesias'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano) iglesias'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano word) iglesias'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano.iglesias)'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias)'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result);
$result = $this->db->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias) CakePHP'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result);
$result = $this->db->conditions(array('Member.name' => '(mariano.iglesias) CakePHP'));
$this->assertPattern('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result);
}
function testArrayConditionsParsing() {
$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);