From f9ee88a5c38ea430bdbe704796ad54fd67ca419f Mon Sep 17 00:00:00 2001 From: pookey Date: Tue, 22 Jan 2008 23:25:20 +0000 Subject: [PATCH] moving ticket to all branches --- tests/Ticket/741TestCase.php | 90 ++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/Ticket/741TestCase.php diff --git a/tests/Ticket/741TestCase.php b/tests/Ticket/741TestCase.php new file mode 100644 index 000000000..2e0047094 --- /dev/null +++ b/tests/Ticket/741TestCase.php @@ -0,0 +1,90 @@ +tables = array('Parent741', 'Child741'); + parent::prepareTables(); + } + + public function testTicket() + { + $moo = new Parent741(); + $moo->amount = 1000; + $cow = new Child741(); + + $moo->Cows[] = $cow; + $cow->Moo = $moo; + $moo->save(); + $this->assertEqual($moo->amount, 0); + } + +} + + + +class Parent741 extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->hasColumn('id', 'integer', 4, array ( + 'primary' => true, + 'autoincrement' => true, + 'notnull' => true, + )); + + $this->hasColumn('amount', 'integer'); + } + + public function setUp() + { + $this->hasMany('Child741 as Cows', array('local' => 'id', 'foreign' => 'moo_id')); + } +} + +class Child741 extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->hasColumn('id', 'integer', 4, array ( + 'primary' => true, + 'autoincrement' => true, + 'notnull' => true, + )); + + $this->hasColumn('moo_id', 'integer'); + } + + public function setUp() + { + $this->hasOne('Parent741 as Moo', array('local' => 'moo_id', 'foreign' => 'id')); + } + + public function postInsert($e) + { + + //echo "State: ". $this->Moo->state() . " \t Amount: " . $this->Moo->amount . "\n"; + $this->Moo->amount = 0; + //echo "State: ". $this->Moo->state() . " \t Amount: " . $this->Moo->amount . "\n"; + $this->Moo->save(); + //echo "State: ". $this->Moo->state() . " \t Amount: " . $this->Moo->amount . "\n"; + $this->Moo->refresh(); + //echo "State: ". $this->Moo->state() . " \t Amount: " . $this->Moo->amount . "\n"; + /* + This outputs the following + State: 6 Amount: 1000 + State: 6 Amount: 0 + State: 6 Amount: 0 + State: 3 Amount: 1000 + + */ + } +} + +