Skip to content
Permalink
Browse files

Unit testing append when combined with insert

  • Loading branch information...
lorenzo committed Oct 21, 2013
1 parent b67e133 commit 64f3eb130d83a579680d90fd67652d2b39ffbc4e
Showing with 20 additions and 1 deletion.
  1. +20 −1 Cake/Test/TestCase/Database/QueryTest.php
@@ -1953,9 +1953,28 @@ public function testAppendSelect() {
$this->assertContains('SELECT', $sql);
$this->assertContains('FROM', $sql);
$this->assertContains('WHERE', $sql);
$this->assertEquals('FOR UPDATE', substr($sql, -10));
$this->assertEquals(' FOR UPDATE', substr($sql, -11));
}
/**
* Test that append() will actually append a string to a select query
*
* @return void
*/
public function testAppendInsert() {
$query = new Query($this->connection);
$sql = $query
->insert('articles', ['id', 'title'])
->values([1, 'a title'])
->append('RETURNING id')
->sql();
$this->assertContains('INSERT', $sql);
$this->assertContains('INTO', $sql);
$this->assertContains('VALUES', $sql);
$this->assertEquals(' RETURNING id', substr($sql, -13));
}
/**
* Assertion for comparing a table's contents with what is in it.
*

0 comments on commit 64f3eb1

Please sign in to comment.
You can’t perform that action at this time.