Updating test for booleans in postgres

This commit is contained in:
José Lorenzo Rodríguez 2010-10-26 21:46:29 -04:30
parent d9222cf90a
commit b3d8a619a3
2 changed files with 14 additions and 10 deletions

View file

@ -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;

View file

@ -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");
}