Commit 91988123 authored by doctrine's avatar doctrine

--no commit message

--no commit message
parent 4cf838a5
...@@ -102,11 +102,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection { ...@@ -102,11 +102,13 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
$query .= ($c > 1)?"id IN (":"id = "; $query .= ($c > 1)?"id IN (":"id = ";
$query .= substr(str_repeat("?, ",count($a)),0,-2); $query .= substr(str_repeat("?, ",count($a)),0,-2);
$query .= ($c > 1)?")":""; $query .= ($c > 1)?")":"";
$query .= " ORDER BY id ASC";
$stmt = $this->table->getSession()->execute($query,array_values($a)); $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); $row = $stmt->fetch(PDO::FETCH_ASSOC);
if($row === false) if($row === false)
break; break;
......
...@@ -13,8 +13,40 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase { ...@@ -13,8 +13,40 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
$user = $graph->query("FROM User"); $user = $graph->query("FROM User");
foreach($user[1]->Group as $group) { 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 { ...@@ -3,8 +3,6 @@ class Entity extends Doctrine_Record {
public function setUp() { public function setUp() {
$this->ownsOne("Email","Entity.email_id"); $this->ownsOne("Email","Entity.email_id");
$this->ownsMany("Phonenumber","Phonenumber.entity_id"); $this->ownsMany("Phonenumber","Phonenumber.entity_id");
$this->hasMany("Address","Entityaddress.address_id");
$this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH); $this->setAttribute(Doctrine::ATTR_FETCHMODE,Doctrine::FETCH_BATCH);
} }
public function setTableDefinition() { public function setTableDefinition() {
...@@ -25,7 +23,7 @@ class EntityAddress extends Doctrine_Record { ...@@ -25,7 +23,7 @@ class EntityAddress extends Doctrine_Record {
} }
class Address extends Doctrine_Record { class Address extends Doctrine_Record {
public function setUp() { public function setUp() {
$this->hasMany("Entity","Entityaddress.entity_id"); $this->hasMany("User","Entityaddress.entity_id");
} }
public function setTableDefinition() { public function setTableDefinition() {
$this->hasColumn("address","string",200); $this->hasColumn("address","string",200);
...@@ -63,6 +61,7 @@ class UserTable extends Doctrine_Table { } ...@@ -63,6 +61,7 @@ class UserTable extends Doctrine_Table { }
class User extends Entity { class User extends Entity {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->hasMany("Address","Entityaddress.address_id");
$this->ownsMany("Album","Album.user_id"); $this->ownsMany("Album","Album.user_id");
$this->hasMany("Group","Groupuser.group_id"); $this->hasMany("Group","Groupuser.group_id");
$this->setInheritanceMap(array("type"=>0)); $this->setInheritanceMap(array("type"=>0));
......
...@@ -24,7 +24,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests"); ...@@ -24,7 +24,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
/**
$test->addTestCase(new Doctrine_RecordTestCase()); $test->addTestCase(new Doctrine_RecordTestCase());
...@@ -39,17 +39,16 @@ $test->addTestCase(new Doctrine_AccessTestCase()); ...@@ -39,17 +39,16 @@ $test->addTestCase(new Doctrine_AccessTestCase());
$test->addTestCase(new Doctrine_EventListenerTestCase()); $test->addTestCase(new Doctrine_EventListenerTestCase());
*/
$test->addTestCase(new Doctrine_BatchIteratorTestCase()); $test->addTestCase(new Doctrine_BatchIteratorTestCase());
/**
$test->addTestCase(new Doctrine_DQL_ParserTestCase()); $test->addTestCase(new Doctrine_DQL_ParserTestCase());
$test->addTestCase(new Doctrine_CollectionTestCase()); $test->addTestCase(new Doctrine_CollectionTestCase());
$test->addTestCase(new Doctrine_ConfigurableTestCase()); $test->addTestCase(new Doctrine_ConfigurableTestCase());
$test->addTestCase(new Sensei_UnitTestCase()); $test->addTestCase(new Sensei_UnitTestCase());
*/
//$test->addTestCase(new Doctrine_Cache_FileTestCase()); //$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment