From 83ceef045d5f6bad03e7726dbca174dc73e377e7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 23 Mar 2012 21:15:11 -0400 Subject: [PATCH] Removing tests that fail on Postgres and Sqlite. Fixes #2174 --- lib/Cake/Test/Case/Model/ModelWriteTest.php | 43 +++++++-------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index ed15e6189..006e1c6e8 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -6078,52 +6078,39 @@ class ModelWriteTest extends BaseModelTest { $result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count'))); $this->assertEquals(array(6, 4, 5, 2), $result); } - + public function testToggleBoolFields() { - $this->loadFixtures('CounterCachePost'); + $this->loadFixtures('CounterCacheUser', 'CounterCachePost'); $Post = new CounterCachePost(); $Post->unbindModel(array('belongsTo' => array('User')), true); - + $true = array('Post' => array('published' => true, 'id' => 2)); $false = array('Post' => array('published' => false, 'id' => 2)); $fields = array('Post.published', 'Post.id'); $updateConditions = array('Post.id' => 2); - + // check its true $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); $this->assertEqual($result, $true); - + // Testing without the alias - $this->assertTrue($Post->updateAll(array('published' => '1 - published'), $updateConditions)); + $this->assertTrue($Post->updateAll(array('published' => 'NOT published'), $updateConditions)); $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); $this->assertEqual($result, $false); - - $this->assertTrue($Post->updateAll(array('published' => '1 - published'), $updateConditions)); + + $this->assertTrue($Post->updateAll(array('published' => 'NOT published'), $updateConditions)); $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); $this->assertEqual($result, $true); - + + $db = ConnectionManager::getDataSource('test'); + $alias = $db->name('Post.published'); + // Testing with the alias - $this->assertTrue($Post->updateAll(array('Post.published' => '1 - Post.published'), $updateConditions)); + $this->assertTrue($Post->updateAll(array('Post.published' => "NOT $alias"), $updateConditions)); $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); $this->assertEqual($result, $false); - - $this->assertTrue($Post->updateAll(array('Post.published' => '1 - Post.published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); - $this->assertEqual($result, $true); - - $this->assertTrue($Post->updateAll(array('Post.published = 1 - Post.published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); - $this->assertEqual($result, $false); - - $this->assertTrue($Post->updateAll(array('Post.published = 1 - Post.published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); - $this->assertEqual($result, $true); - - $this->assertTrue($Post->updateAll(array('Post.published' => '! Post.published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); - $this->assertEqual($result, $false); - - $this->assertTrue($Post->updateAll(array('Post.published' => 'NOT Post.published'), $updateConditions)); + + $this->assertTrue($Post->updateAll(array('Post.published' => "NOT $alias"), $updateConditions)); $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); $this->assertEqual($result, $true); }