Skip to content

Commit

Permalink
Corrected the return type in the docblock and added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
David Yell committed Apr 28, 2015
1 parent 363af9e commit 6fb3b4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ORM/AssociationCollection.php
Expand Up @@ -294,11 +294,11 @@ public function normalizeKeys($keys)

return $this->_normalizeAssociations($keys);
}

/**
* Allow looping through the associations
*
* @return \Cake\ORM\Association
*
* @return ArrayIterator
*/
public function getIterator()
{
Expand Down
21 changes: 21 additions & 0 deletions tests/TestCase/ORM/AssociationCollectionTest.php
Expand Up @@ -367,4 +367,25 @@ public function testNormalizeKeys()
$expected = ['users' => [], 'categories' => []];
$this->assertSame($expected, $this->associations->normalizeKeys(true));
}

/**
* Ensure that the association collection can be iterated.
*
* @return void
*/
public function testAssociationsCanBeIterated()
{
$belongsTo = new BelongsTo('');
$this->associations->add('Users', $belongsTo);
$belongsToMany = new BelongsToMany('');
$this->associations->add('Cart', $belongsToMany);

foreach ($this->associations as $name => $association) {
if ($name === 'users') {
$this->assertInstanceOf('Cake\ORM\Association\BelongsTo', $association);
} else {
$this->assertInstanceOf('Cake\ORM\Association\BelongsToMany', $association);
}
}
}
}

0 comments on commit 6fb3b4d

Please sign in to comment.