From b3d8a619a3d5de7bd3177750033091f35f828719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2010 21:46:29 -0430 Subject: [PATCH] Updating test for booleans in postgres --- .../model/datasources/dbo/dbo_postgres.php | 4 ++++ .../datasources/dbo/dbo_postgres.test.php | 20 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 63b069199..313036ac5 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -732,12 +732,16 @@ class DboPostgres extends DboSource { switch (true) { case ($data === true || $data === false): $result = $data; + break; case ($data === 't' || $data === 'f'): $result = ($data === 't'); + break; case ($data === 'true' || $data === 'false'): $result = ($data === 'true'); + break; case ($data === 'TRUE' || $data === 'FALSE'): $result = ($data === 'TRUE'); + break; default: $result = (bool) $data; break; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index f82e49c1f..049ca1d9a 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -340,18 +340,18 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->Dbo->value('', 'float', false), "NULL"); $this->assertEqual($this->Dbo->value('0.0', 'float'), "'0.0'"); - $this->assertEqual($this->Dbo->value('t', 'boolean'), true); - $this->assertEqual($this->Dbo->value('f', 'boolean'), false); - $this->assertEqual($this->Dbo->value(true), true); - $this->assertEqual($this->Dbo->value(false), false); + $this->assertEqual($this->Dbo->value('t', 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('f', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(true), "'TRUE'"); + $this->assertEqual($this->Dbo->value(false), "'FALSE'"); $this->assertEqual($this->Dbo->value('t'), "'t'"); $this->assertEqual($this->Dbo->value('f'), "'f'"); - $this->assertEqual($this->Dbo->value('true', 'boolean'), true); - $this->assertEqual($this->Dbo->value('false', 'boolean'), false); - $this->assertEqual($this->Dbo->value('', 'boolean'), false); - $this->assertEqual($this->Dbo->value(0, 'boolean'), false); - $this->assertEqual($this->Dbo->value(1, 'boolean'), true); - $this->assertEqual($this->Dbo->value('1', 'boolean'), true); + $this->assertEqual($this->Dbo->value('true', 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('false', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value('', 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(0, 'boolean'), "'FALSE'"); + $this->assertEqual($this->Dbo->value(1, 'boolean'), "'TRUE'"); + $this->assertEqual($this->Dbo->value('1', 'boolean'), "'TRUE'"); $this->assertEqual($this->Dbo->value(null, 'boolean'), "NULL"); $this->assertEqual($this->Dbo->value(array()), "NULL"); }