From 5d8ac6d0a02749d7459e82b01b4c38059b91045a Mon Sep 17 00:00:00 2001 From: pookey Date: Mon, 16 Oct 2006 18:10:38 +0000 Subject: [PATCH] pookey: adding test cases for Doctrine_Record::copy refs #172 --- tests/RecordTestCase.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/RecordTestCase.php b/tests/RecordTestCase.php index 07dc1e715..60e3c3fe6 100644 --- a/tests/RecordTestCase.php +++ b/tests/RecordTestCase.php @@ -652,11 +652,33 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase { $this->assertTrue($new instanceof Doctrine_Record); $this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY); + $new = $user->copy(); $new->save(); + $this->assertEqual($user->name, $new->name); $this->assertTrue(is_numeric($new->id) && $new->id > 0); - $new->refresh(); $this->assertEqual($user->name, $new->name); + $this->assertTrue(is_numeric($new->id) && $new->id > 0); + } + + public function testCopyAndModify() { + $user = $this->connection->getTable("User")->find(4); + $new = $user->copy(); + + $this->assertTrue($new instanceof Doctrine_Record); + $this->assertTrue($new->getState() == Doctrine_Record::STATE_TDIRTY); + + $new->loginname = 'jackd'; + + $this->assertEqual($user->name, $new->name); + $this->assertEqual($new->loginname, 'jackd'); + + $new->save(); + $this->assertTrue(is_numeric($new->id) && $new->id > 0); + + $new->refresh(); + $this->assertEqual($user->name, $new->name); + $this->assertEqual($new->loginname, 'jackd'); } public function testReferences() {