Skip to content

Commit

Permalink
Removing Query::sql(false) usages and removing tests that were asserting
Browse files Browse the repository at this point in the history
on an dialect specific sql as sql() will always return the transformed
version
  • Loading branch information
lorenzo committed Jun 20, 2013
1 parent f82b701 commit e31909a
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions lib/Cake/Test/TestCase/Database/QueryTest.php
Expand Up @@ -1493,7 +1493,7 @@ public function testDeleteWithFrom() {
->from('authors')
->where('1 = 1');

$result = $query->sql(false);
$result = $query->sql();
$this->assertContains('DELETE FROM authors', $result);

$result = $query->execute();
Expand All @@ -1512,7 +1512,7 @@ public function testDeleteNoFrom() {
$query->delete('authors')
->where('1 = 1');

$result = $query->sql(false);
$result = $query->sql();
$this->assertContains('DELETE FROM authors ', $result);

$result = $query->execute();
Expand All @@ -1530,7 +1530,7 @@ public function testSelectAndDeleteOnSameQuery() {
$result = $query->select()
->delete('authors')
->where('1 = 1');
$result = $query->sql(false);
$result = $query->sql();

$this->assertContains('DELETE FROM authors', $result);
$this->assertContains('authors WHERE 1 = 1', $result);
Expand All @@ -1546,7 +1546,7 @@ public function testUpdateSimple() {
$query->update('authors')
->set('name', 'mark')
->where(['id' => 1]);
$result = $query->sql(false);
$result = $query->sql();
$this->assertContains('UPDATE authors SET name = :', $result);

$result = $query->execute();
Expand All @@ -1564,7 +1564,7 @@ public function testUpdateMultipleFields() {
->set('title', 'mark', 'string')
->set('body', 'some text', 'string')
->where(['id' => 1]);
$result = $query->sql(false);
$result = $query->sql();

$this->assertRegExp(
'/UPDATE articles SET title = :[0-9a-z]+ , body = :[0-9a-z]+/',
Expand All @@ -1589,7 +1589,7 @@ public function testUpdateMultipleFieldsArray() {
'body' => 'some text'
], ['title' => 'string', 'body' => 'string'])
->where(['id' => 1]);
$result = $query->sql(false);
$result = $query->sql();

$this->assertRegExp(
'/UPDATE articles SET title = :[0-9a-z]+ , body = :[0-9a-z]+/',
Expand All @@ -1615,7 +1615,7 @@ public function testUpdateWithExpression() {
$query->update('articles')
->set($expr)
->where(['id' => 1]);
$result = $query->sql(false);
$result = $query->sql();

$this->assertContains(
'UPDATE articles SET title = author_id WHERE id = :',
Expand Down Expand Up @@ -1653,7 +1653,7 @@ public function testInsertSimple() {
'title' => 'mark',
'body' => 'test insert'
]);
$result = $query->sql(false);
$result = $query->sql();
$this->assertEquals(
'INSERT INTO articles (title, body) VALUES (?, ?)',
$result
Expand Down Expand Up @@ -1686,7 +1686,7 @@ public function testInsertSparseRow() {
->values([
'title' => 'mark',
]);
$result = $query->sql(false);
$result = $query->sql();
$this->assertEquals(
'INSERT INTO articles (title, body) VALUES (?, ?)',
$result
Expand Down Expand Up @@ -1721,11 +1721,6 @@ public function testInsertMultipleRowsSparse() {
->values([
'title' => 'jose',
]);
$result = $query->sql(false);
$this->assertEquals(
'INSERT INTO articles (title, body) VALUES (?, ?), (?, ?)',
$result
);

$result = $query->execute();
$this->assertCount(2, $result, '2 rows should be inserted');
Expand Down Expand Up @@ -1767,7 +1762,7 @@ public function testInsertFromSelect() {
)
->values($select);

$result = $query->sql(false);
$result = $query->sql();
$this->assertContains('INSERT INTO articles (title, body, author_id) SELECT', $result);
$this->assertContains("SELECT name, 'some text', 99 FROM authors", $result);
$result = $query->execute();
Expand Down

0 comments on commit e31909a

Please sign in to comment.