From 8555ff5fb3f3367f81589df3bb6ea3717ac78565 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 31 Dec 2012 19:57:30 +0100 Subject: [PATCH] Adding missing test case form previous commit --- .../Model/Datasource/Database/QueryTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Cake/Test/TestCase/Model/Datasource/Database/QueryTest.php b/lib/Cake/Test/TestCase/Model/Datasource/Database/QueryTest.php index cba8372d71b..a40e05aeff5 100644 --- a/lib/Cake/Test/TestCase/Model/Datasource/Database/QueryTest.php +++ b/lib/Cake/Test/TestCase/Model/Datasource/Database/QueryTest.php @@ -467,4 +467,21 @@ public function testSelectOrWhereNoPreviousCondition() { $this->assertEquals(['id' => 2], $result->fetch('assoc')); } +/** + * Tests that Query::andWhere() can be used without calling where() before + * + * @return void + **/ + public function testSelectAndWhereNoPreviousCondition() { + $this->_insertDateRecords(); + $query = new Query($this->connection); + $result = $query + ->select(['id']) + ->from('dates') + ->andWhere(['posted' => new \DateTime('2012-12-21 12:00')], ['posted' => 'datetime']) + ->andWhere(['id' => 1]) + ->execute(); + $this->assertCount(1, $result); + $this->assertEquals(['id' => 1], $result->fetch('assoc')); + } }