mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
9ba943ed6b
commit
6adef29257
1 changed files with 12 additions and 0 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue