From 9bc5afd0f84e5d7f0c0c58bb3c8339107f843901 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 21 Oct 2013 21:35:39 +0200 Subject: [PATCH] Unit testing append in combination with update --- Cake/Test/TestCase/Database/QueryTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Cake/Test/TestCase/Database/QueryTest.php b/Cake/Test/TestCase/Database/QueryTest.php index 79984ffb05d..899628b83a9 100644 --- a/Cake/Test/TestCase/Database/QueryTest.php +++ b/Cake/Test/TestCase/Database/QueryTest.php @@ -1974,6 +1974,24 @@ public function testAppendInsert() { $this->assertEquals(' RETURNING id', substr($sql, -13)); } +/** + * Test that append() will actually append a string to a select query + * + * @return void + */ + public function testAppendUpdate() { + $query = new Query($this->connection); + $sql = $query + ->update('articles') + ->set(['title' => 'foo']) + ->where(['id' => 1]) + ->append('RETURNING id') + ->sql(); + $this->assertContains('UPDATE', $sql); + $this->assertContains('SET', $sql); + $this->assertContains('WHERE', $sql); + $this->assertEquals(' RETURNING id', substr($sql, -13)); + } /** * Assertion for comparing a table's contents with what is in it.