2006-04-14 00:37:28 +04:00
|
|
|
<?php
|
|
|
|
class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
|
2006-05-15 16:15:20 +04:00
|
|
|
public function prepareData() { }
|
2006-08-08 13:07:55 +04:00
|
|
|
public function prepareTables() {
|
|
|
|
$this->tables = array("Entity", "User");
|
2006-08-22 03:20:33 +04:00
|
|
|
parent::prepareTables();
|
2006-08-08 13:07:55 +04:00
|
|
|
}
|
2006-09-14 00:47:29 +04:00
|
|
|
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]));
|
|
|
|
}
|
2006-04-14 00:37:28 +04:00
|
|
|
public function testOffsetMethods() {
|
2006-05-15 16:15:20 +04:00
|
|
|
$user = new User();
|
|
|
|
$this->assertEqual($user["name"],null);
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-05-15 16:15:20 +04:00
|
|
|
$user["name"] = "Jack";
|
|
|
|
$this->assertEqual($user["name"],"Jack");
|
|
|
|
|
|
|
|
$user->save();
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-09-17 21:59:04 +04:00
|
|
|
$user = $this->connection->getTable("User")->find($user->obtainIdentifier());
|
2006-05-15 16:15:20 +04:00
|
|
|
$this->assertEqual($user->name,"Jack");
|
|
|
|
|
|
|
|
$user["name"] = "Jack";
|
|
|
|
$this->assertEqual($user["name"],"Jack");
|
|
|
|
$user["name"] = "zYne";
|
|
|
|
$this->assertEqual($user["name"],"zYne");
|
2006-04-14 00:37:28 +04:00
|
|
|
}
|
|
|
|
public function testOverload() {
|
2006-05-15 16:15:20 +04:00
|
|
|
$user = new User();
|
|
|
|
$this->assertEqual($user->name,null);
|
|
|
|
|
|
|
|
$user->name = "Jack";
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-05-15 16:15:20 +04:00
|
|
|
$this->assertEqual($user->name,"Jack");
|
|
|
|
|
|
|
|
$user->save();
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-09-17 21:59:04 +04:00
|
|
|
$user = $this->connection->getTable("User")->find($user->obtainIdentifier());
|
2006-05-15 16:15:20 +04:00
|
|
|
$this->assertEqual($user->name,"Jack");
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-05-15 16:15:20 +04:00
|
|
|
$user->name = "Jack";
|
|
|
|
$this->assertEqual($user->name,"Jack");
|
|
|
|
$user->name = "zYne";
|
|
|
|
$this->assertEqual($user->name,"zYne");
|
2006-04-14 00:37:28 +04:00
|
|
|
}
|
|
|
|
public function testSet() {
|
2006-05-15 16:15:20 +04:00
|
|
|
$user = new User();
|
|
|
|
$this->assertEqual($user->get("name"),null);
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-05-15 16:15:20 +04:00
|
|
|
$user->set("name","Jack");
|
|
|
|
$this->assertEqual($user->get("name"),"Jack");
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-05-15 16:15:20 +04:00
|
|
|
$user->save();
|
2006-04-14 00:37:28 +04:00
|
|
|
|
2006-09-17 21:59:04 +04:00
|
|
|
$user = $this->connection->getTable("User")->find($user->obtainIdentifier());
|
2006-05-15 16:15:20 +04:00
|
|
|
|
|
|
|
$this->assertEqual($user->get("name"),"Jack");
|
|
|
|
|
|
|
|
$user->set("name","Jack");
|
|
|
|
$this->assertEqual($user->get("name"),"Jack");
|
2006-04-14 00:37:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|