1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/tests/AccessTestCase.php
zYne 41ee9173f1 method name changes for better custom getter/setter compatibility
Doctrine_Record::getID() -> obtainIdentifier()
Doctrine_Record::setID() -> assignIdentifier()
2006-09-17 17:59:04 +00:00

86 lines
2.5 KiB
PHP

<?php
class Doctrine_AccessTestCase 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->getTable("User")->find($user->obtainIdentifier());
$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->getTable("User")->find($user->obtainIdentifier());
$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->getTable("User")->find($user->obtainIdentifier());
$this->assertEqual($user->get("name"),"Jack");
$user->set("name","Jack");
$this->assertEqual($user->get("name"),"Jack");
}
}
?>