From 7ef7031c37dd7372a80f216cf2264c419125b0a5 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 7 Sep 2006 21:30:21 +0000 Subject: [PATCH] toArray test cases --- tests/RecordTestCase.php | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/RecordTestCase.php b/tests/RecordTestCase.php index 7e586e0a9..1f3d294c5 100644 --- a/tests/RecordTestCase.php +++ b/tests/RecordTestCase.php @@ -7,7 +7,49 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase { $this->tables[] = "enumTest"; parent::prepareTables(); } - + public function testToArray() { + $user = new User(); + + $a = $user->toArray(); + + $this->assertTrue(is_array($a)); + $this->assertTrue(array_key_exists('name', $a)); + $this->assertEqual($a['name'], null); + $this->assertTrue(array_key_exists('id', $a)); + $this->assertEqual($a['id'], null); + + $user->name = 'Someone'; + + $user->save(); + + $a = $user->toArray(); + + $this->assertTrue(is_array($a)); + $this->assertTrue(array_key_exists('name', $a)); + $this->assertEqual($a['name'], 'Someone'); + $this->assertTrue(array_key_exists('id', $a)); + $this->assertEqual($a['id'], 12); + + $user->refresh(); + + $a = $user->toArray(); + + $this->assertTrue(is_array($a)); + $this->assertTrue(array_key_exists('name', $a)); + $this->assertEqual($a['name'], 'Someone'); + $this->assertTrue(array_key_exists('id', $a)); + $this->assertEqual($a['id'], 12); + $this->connection->clear(); + $user = $user->getTable()->find($user->id); + + $a = $user->toArray(); + + $this->assertTrue(is_array($a)); + $this->assertTrue(array_key_exists('name', $a)); + $this->assertEqual($a['name'], 'Someone'); + $this->assertTrue(array_key_exists('id', $a)); + $this->assertEqual($a['id'], 12); + } public function testReferences2() { $user = new User();