1
0
mirror of synced 2024-12-13 06:46:03 +03:00

toArray test cases

This commit is contained in:
zYne 2006-09-07 21:30:21 +00:00
parent 65c9e56c86
commit 7ef7031c37

View File

@ -7,7 +7,49 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->tables[] = "enumTest"; $this->tables[] = "enumTest";
parent::prepareTables(); 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() { public function testReferences2() {
$user = new User(); $user = new User();