diff --git a/tests/TestCase/ORM/AssociationCollectionTest.php b/tests/TestCase/ORM/AssociationCollectionTest.php index b7a74eac71f..c2d6abeec21 100644 --- a/tests/TestCase/ORM/AssociationCollectionTest.php +++ b/tests/TestCase/ORM/AssociationCollectionTest.php @@ -380,12 +380,8 @@ public function testAssociationsCanBeIterated() $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); - } - } + $expected = ['users' => $belongsTo, 'cart' => $belongsToMany]; + $result = iterator_to_array($this->associations, true); + $this->assertSame($expected, $result); } }