Adding a couple of tests to ensure proper parsing of GROUP BY queries

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5345 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-06-25 14:48:20 +00:00
parent 9ba943ed6b
commit 6adef29257

View file

@ -1623,6 +1623,14 @@ class DboSourceTest extends UnitTestCase {
$result = $this->db->conditions($conditions);
$expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'";
$this->assertEqual($result, $expected);
$conditions = array(
'Thread.project_id' => 5,
'Thread.buyer_id' => 14,
'1=1 GROUP BY Thread.project_id'
);
$result = $this->db->conditions($conditions);
$this->assertPattern('/^\s*WHERE\s+`Thread`.`project_id`\s*=\s*5\s+AND\s+`Thread`.`buyer_id`\s*=\s*14\s+AND\s+1\s*=\s*1\s+GROUP BY `Thread`.`project_id`$/', $result);
}
function testFieldParsing() {
$result = $this->db->fields($this->model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`");
@ -1684,6 +1692,10 @@ class DboSourceTest extends UnitTestCase {
$result = $this->db->fields($this->model, null, 'COUNT(*)');
$expected = array('COUNT(*)');
$this->assertEqual($result, $expected);
$result = $this->db->fields($this->model, null, 'SUM(Thread.unread_buyer) AS ' . $this->db->name('sum_unread_buyer'));
$expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`');
$this->assertEqual($result, $expected);
}
function testMergeAssociations() {