From 9589f486ef4a957c6b1ae00c61463e97c9607622 Mon Sep 17 00:00:00 2001 From: pookey Date: Mon, 2 Oct 2006 01:31:07 +0000 Subject: [PATCH] pookey: added boolean test cases for setting null values --- tests/BooleanTestCase.php | 23 +++++++++++++++++++++++ tests/classes.php | 1 + 2 files changed, 24 insertions(+) diff --git a/tests/BooleanTestCase.php b/tests/BooleanTestCase.php index 953fc28b2..f9a49df1b 100644 --- a/tests/BooleanTestCase.php +++ b/tests/BooleanTestCase.php @@ -5,6 +5,29 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase { $this->tables = array("BooleanTest"); parent::prepareTables(); } + + public function testSetNull() { + $test = new BooleanTest(); + $this->is_working = null; + + $this->assertEqual($this->is_working, null); + $this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY); + $test->save(); + + $test->refresh(); + $this->assertEqual($test->is_working, null); + + $test = new BooleanTest(); + $this->is_working_notnull = null; + + $this->assertEqual($this->is_working_notnull, false); + $this->assertEqual($test->getState(), Doctrine_Record::STATE_TDIRTY); + $test->save(); + + $test->refresh(); + $this->assertEqual($test->is_working_notnull, false); + } + public function testSetFalse() { $test = new BooleanTest(); $test->is_working = false; diff --git a/tests/classes.php b/tests/classes.php index 39c6d08fd..99344f7b1 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -458,6 +458,7 @@ class Phototag extends Doctrine_Record { class BooleanTest extends Doctrine_Record { public function setTableDefinition() { $this->hasColumn('is_working', 'boolean'); + $this->hasColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true)); } } class Data_File extends Doctrine_Record {