. */ /** * Doctrine_Access_TestCase * * @package Doctrine * @author Konsta Vesterinen * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 * @version $Revision$ */ class Doctrine_Access_TestCase extends Doctrine_UnitTestCase { public function prepareData() { } public function prepareTables() { $this->tables = array('Entity', 'User'); parent::prepareTables(); } public function testUnset() { } public function testIsset() { $user = new User(); $this->assertTrue(isset($user->name)); $this->assertFalse(isset($user->unknown)); $this->assertTrue(isset($user['name'])); $this->assertFalse(isset($user['unknown'])); $coll = new Doctrine_Collection('User'); $this->assertFalse(isset($coll[0])); // test repeated call $this->assertFalse(isset($coll[0])); $coll[0]; $this->assertTrue(isset($coll[0])); // test repeated call $this->assertTrue(isset($coll[0])); } public function testOffsetMethods() { $user = new User(); $this->assertEqual($user['name'], null); $user['name'] = 'Jack'; $this->assertEqual($user['name'], 'Jack'); $user->save(); $user = $this->connection->getMapper('User')->find($user->identifier()); $this->assertEqual($user->name, 'Jack'); $user['name'] = 'Jack'; $this->assertEqual($user['name'], 'Jack'); $user['name'] = 'zYne'; $this->assertEqual($user['name'], 'zYne'); } public function testOverload() { $user = new User(); $this->assertEqual($user->name,null); $user->name = 'Jack'; $this->assertEqual($user->name, 'Jack'); $user->save(); $user = $this->connection->getMapper('User')->find($user->identifier()); $this->assertEqual($user->name, 'Jack'); $user->name = 'Jack'; $this->assertEqual($user->name, 'Jack'); $user->name = 'zYne'; $this->assertEqual($user->name, 'zYne'); } public function testSet() { $user = new User(); $this->assertEqual($user->get('name'),null); $user->set('name', 'Jack'); $this->assertEqual($user->get('name'), 'Jack'); $user->save(); $user = $this->connection->getMapper('User')->find($user->identifier()); $this->assertEqual($user->get('name'), 'Jack'); $user->set('name', 'Jack'); $this->assertEqual($user->get('name'), 'Jack'); } }