My problem is that I have to mock a class which extends \ArrayObject and I want to use this mocked object in a foreach, but I get this exception:
Exception: Objects returned by Mock_ItemCollection_3ab4029b::getIterator() must be traversable or implement interface Iterator
I've checked the manual and the actual types in code (with instanceof) and the object I get is Traversable (but not Iterator).
How can I solve this problem? (BTW, the original class works great with foreach)
Update: This is how I try to mock the class:
class ItemCollection extends \ArrayObject implements StatefulInterface, ItemCollectionInterface {...}
$mockIC = $this->getMockBuilder('\SK\API\Model\ItemCollection\ItemCollection')
->setConstructorArgs(array($this->container->get('mongo.db')))
->getMock();