Skip to content

Commit

Permalink
Fixing some tests for Postgres Dbo and adding test cverage for extra …
Browse files Browse the repository at this point in the history
…params in order function, closes #353
  • Loading branch information
lorenzo committed Mar 9, 2010
1 parent a79ff50 commit acccf96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -677,7 +677,7 @@ function testAlterIndexes() {
*/
function testVirtualFields() {
$this->loadFixtures('Article', 'Comment');
$Article =& ClassRegistry::init('Article');
$Article = new Article;
$Article->virtualFields = array(
'next_id' => 'Article.id + 1',
'complex' => 'Article.title || Article.body',
Expand All @@ -690,5 +690,14 @@ function testVirtualFields() {
$this->assertEqual($result['Article']['functional'], $result['Article']['title']);
$this->assertEqual($result['Article']['subquery'], 6);
}

/**
* Tests additional order options for postgres
*/
function testOrderAdditionalParams() {
$result = $this->db->order(array('title' => 'DESC NULLS FIRSTS', 'body' => 'DESC'));
$expected = ' ORDER BY "title" DESC NULLS FIRSTS, "body" DESC';
$this->assertEqual($result, $expected);
}
}
?>
8 changes: 7 additions & 1 deletion cake/tests/cases/libs/model/model_read.test.php
Expand Up @@ -76,7 +76,7 @@ function testFetchingNonUniqueFKJoinTableRecords() {
function testGroupBy() {
$db = ConnectionManager::getDataSource('test_suite');
$isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle'));
$message = '%s Postgresql and Oracle have strict GROUP BY and are incompatible with this test.';
$message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.';

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

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

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

Expand Down

0 comments on commit acccf96

Please sign in to comment.