This commit is contained in:
parent
4cf838a583
commit
91988123a0
@ -102,11 +102,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
|
||||
$query .= ($c > 1)?"id IN (":"id = ";
|
||||
$query .= substr(str_repeat("?, ",count($a)),0,-2);
|
||||
$query .= ($c > 1)?")":"";
|
||||
$query .= " ORDER BY id ASC";
|
||||
|
||||
$stmt = $this->table->getSession()->execute($query,array_values($a));
|
||||
|
||||
foreach($a as $k => $id) {
|
||||
foreach($a as $k => $id) {
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if($row === false)
|
||||
break;
|
||||
|
||||
|
@ -13,8 +13,40 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
|
||||
|
||||
$user = $graph->query("FROM User");
|
||||
foreach($user[1]->Group as $group) {
|
||||
print $group->name;
|
||||
}
|
||||
$this->assertTrue(is_string($group->name));
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$user->name = "tester";
|
||||
|
||||
$user->Address[0]->address = "street 1";
|
||||
$user->Address[1]->address = "street 2";
|
||||
|
||||
$this->assertEqual($user->name, "tester");
|
||||
$this->assertEqual($user->Address[0]->address, "street 1");
|
||||
$this->assertEqual($user->Address[1]->address, "street 2");
|
||||
|
||||
foreach($user->Address as $address) {
|
||||
$a[] = $address->address;
|
||||
}
|
||||
$this->assertEqual($a, array("street 1", "street 2"));
|
||||
|
||||
$user->save();
|
||||
|
||||
$user = $user->getTable()->find($user->getID());
|
||||
$this->assertEqual($user->name, "tester");
|
||||
$this->assertEqual($user->Address[0]->address, "street 1");
|
||||
$this->assertEqual($user->Address[1]->address, "street 2");
|
||||
|
||||
$user = $user->getTable()->find($user->getID());
|
||||
$a = array();
|
||||
foreach($user->Address as $address) {
|
||||
$a[] = $address->address;
|
||||
}
|
||||
$this->assertEqual($a, array("street 1", "street 2"));
|
||||
|
||||
|
||||
$user = $graph->query("FROM User");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,6 @@ class Entity extends Doctrine_Record {
|
||||
public function setUp() {
|
||||
$this->ownsOne("Email","Entity.email_id");
|
||||
$this->ownsMany("Phonenumber","Phonenumber.entity_id");
|
||||
$this->hasMany("Address","Entityaddress.address_id");
|
||||
|
||||
$this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH);
|
||||
}
|
||||
public function setTableDefinition() {
|
||||
@ -25,7 +23,7 @@ class EntityAddress extends Doctrine_Record {
|
||||
}
|
||||
class Address extends Doctrine_Record {
|
||||
public function setUp() {
|
||||
$this->hasMany("Entity","Entityaddress.entity_id");
|
||||
$this->hasMany("User","Entityaddress.entity_id");
|
||||
}
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn("address","string",200);
|
||||
@ -63,6 +61,7 @@ class UserTable extends Doctrine_Table { }
|
||||
class User extends Entity {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->hasMany("Address","Entityaddress.address_id");
|
||||
$this->ownsMany("Album","Album.user_id");
|
||||
$this->hasMany("Group","Groupuser.group_id");
|
||||
$this->setInheritanceMap(array("type"=>0));
|
||||
|
@ -24,7 +24,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
$test->addTestCase(new Doctrine_RecordTestCase());
|
||||
|
||||
@ -39,17 +39,16 @@ $test->addTestCase(new Doctrine_AccessTestCase());
|
||||
|
||||
|
||||
$test->addTestCase(new Doctrine_EventListenerTestCase());
|
||||
*/
|
||||
|
||||
$test->addTestCase(new Doctrine_BatchIteratorTestCase());
|
||||
|
||||
|
||||
/**
|
||||
$test->addTestCase(new Doctrine_DQL_ParserTestCase());
|
||||
|
||||
$test->addTestCase(new Doctrine_CollectionTestCase());
|
||||
$test->addTestCase(new Doctrine_ConfigurableTestCase());
|
||||
$test->addTestCase(new Sensei_UnitTestCase());
|
||||
*/
|
||||
|
||||
|
||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
||||
|
Loading…
Reference in New Issue
Block a user