diff --git a/Doctrine/Collection.php b/Doctrine/Collection.php index ecc211f8e..1f23165ad 100644 --- a/Doctrine/Collection.php +++ b/Doctrine/Collection.php @@ -288,12 +288,12 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator } elseif($this->relation instanceof Doctrine_Association) { $asf = $this->relation->getAssociationFactory(); - $query = "SELECT ".$foreign." FROM ".$asf->getTableName()." WHERE ".$local."=".$this->getIncremented(); + $query = 'SELECT '.$foreign." FROM ".$asf->getTableName()." WHERE ".$local."=".$this->getIncremented(); $table = $fk->getTable(); $graph = new Doctrine_Query($table->getConnection()); - $q = "FROM ".$table->getComponentName()." WHERE ".$table->getComponentName().".".$table->getIdentifier()." IN ($query)"; + $q = 'FROM ' . $table->getComponentName() . ' WHERE ' . $table->getComponentName() . '.' . $table->getIdentifier()." IN ($query)"; } } diff --git a/tests/CollectionTestCase.php b/tests/CollectionTestCase.php index 15cf1611c..4b61daf88 100644 --- a/tests/CollectionTestCase.php +++ b/tests/CollectionTestCase.php @@ -1,5 +1,34 @@ name = 'resource 1'; + $resource[0]->Type[0]->type = 'type 1'; + $resource[0]->Type[1]->type = 'type 2'; + $resource[1]->name = 'resource 2'; + $resource[1]->Type[0]->type = 'type 3'; + $resource[1]->Type[1]->type = 'type 4'; + + $resource->save(); + + $this->connection->clear(); + + $resources = $this->connection->query('FROM Resource'); + + $count = $this->dbh->count(); + $resources->loadRelated('Type'); + + $this->assertEqual(($count + 1), $this->dbh->count()); + $this->assertEqual($resources[0]->name, 'resource 1'); + $this->assertEqual($resource[0]->Type[0]->type, 'type 1'); + $this->assertEqual($resource[0]->Type[1]->type, 'type 2'); + $this->assertEqual(($count + 1), $this->dbh->count()); + + $this->assertEqual($resource[1]->name, 'resource 2'); + $this->assertEqual($resource[1]->Type[0]->type, 'type 3'); + $this->assertEqual($resource[1]->Type[1]->type, 'type 4'); + $this->assertEqual(($count + 1), $this->dbh->count()); + } public function testAdd() { $coll = new Doctrine_Collection($this->objTable); $coll->add(new User()); diff --git a/tests/classes.php b/tests/classes.php index 60b054b62..a3a350dc7 100644 --- a/tests/classes.php +++ b/tests/classes.php @@ -147,7 +147,7 @@ class Task extends Doctrine_Record { class Resource extends Doctrine_Record { public function setUp() { - $this->hasMany("Task as TaskAlias","Assignment.task_id"); + $this->hasMany("Task as TaskAlias", "Assignment.task_id"); $this->hasMany("ResourceType as Type", "ResourceReference.type_id"); } public function setTableDefinition() { diff --git a/tests/run.php b/tests/run.php index 8397f9313..6c1471160 100644 --- a/tests/run.php +++ b/tests/run.php @@ -62,7 +62,7 @@ $test->addTestCase(new Doctrine_Filter_TestCase()); $test->addTestCase(new Doctrine_ValueHolder_TestCase()); -$test->addTestCase(new Doctrine_ValidatorTestCase()); +$test->addTestCase(new Doctrine_ValidatorTestCase()); $test->addTestCase(new Doctrine_QueryTestCase());