Skip to content

Commit acccf96

Browse files
committed
Fixing some tests for Postgres Dbo and adding test cverage for extra params in order function, closes #353
1 parent a79ff50 commit acccf96

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ function testAlterIndexes() {
677677
*/
678678
function testVirtualFields() {
679679
$this->loadFixtures('Article', 'Comment');
680-
$Article =& ClassRegistry::init('Article');
680+
$Article = new Article;
681681
$Article->virtualFields = array(
682682
'next_id' => 'Article.id + 1',
683683
'complex' => 'Article.title || Article.body',
@@ -690,5 +690,14 @@ function testVirtualFields() {
690690
$this->assertEqual($result['Article']['functional'], $result['Article']['title']);
691691
$this->assertEqual($result['Article']['subquery'], 6);
692692
}
693+
694+
/**
695+
* Tests additional order options for postgres
696+
*/
697+
function testOrderAdditionalParams() {
698+
$result = $this->db->order(array('title' => 'DESC NULLS FIRSTS', 'body' => 'DESC'));
699+
$expected = ' ORDER BY "title" DESC NULLS FIRSTS, "body" DESC';
700+
$this->assertEqual($result, $expected);
701+
}
693702
}
694703
?>

cake/tests/cases/libs/model/model_read.test.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function testFetchingNonUniqueFKJoinTableRecords() {
7676
function testGroupBy() {
7777
$db = ConnectionManager::getDataSource('test_suite');
7878
$isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle'));
79-
$message = '%s Postgresql and Oracle have strict GROUP BY and are incompatible with this test.';
79+
$message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
8080

8181
if ($this->skipIf($isStrictGroupBy, $message )) {
8282
return;
@@ -4030,6 +4030,9 @@ function testFindAllWithConditionsHavingMixedDataTypes() {
40304030
$result = $TestModel->find('all', compact('conditions', 'recursive', 'order'));
40314031
$this->assertEqual($result, $expected);
40324032

4033+
if ($this->skipIf($this->db->config['driver'] == 'postgres', 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres')) {
4034+
return;
4035+
}
40334036
$conditions = array('id' => array('1', 2, '3.0'));
40344037
$order = 'Article.id ASC';
40354038
$result = $TestModel->find('all', compact('recursive', 'conditions', 'order'));
@@ -7240,6 +7243,9 @@ function testVirtualFields() {
72407243
$result = $Post->field('other_field');
72417244
$this->assertEqual($result, 4);
72427245

7246+
if ($this->skipIf($this->db->config['driver'] == 'postgres', 'The rest of virtualFieds test is not compatible with Postgres')) {
7247+
return;
7248+
}
72437249
ClassRegistry::flush();
72447250
$Post =& ClassRegistry::init('Post');
72457251

0 commit comments

Comments
 (0)