/** * Test process() method in order to test that collection is well completed. */ public function testProcessMethod() { $action = new Action(); $action->setVerb('a.not.supported.verb'); $spread = $this->getMockBuilder('\\Sonata\\TimelineBundle\\Spread\\AdminSpread')->disableOriginalConstructor()->setMethods(array('getUsers'))->getMock(); $spread->expects($this->any())->method('getUsers')->will($this->returnValue($this->getFakeUsers())); $collection = new EntryCollection(); $spread->process($action, $collection); $this->assertCount(2, $collection->getIterator(), 'Should return 2'); $usersCount = 0; foreach ($collection->getIterator() as $users) { foreach ($users as $entry) { ++$usersCount; $this->assertInstanceOf('Spy\\Timeline\\Spread\\Entry\\EntryUnaware', $entry, 'Should return an instance of EntryUnaware'); } } $this->assertEquals(5, $usersCount / 2, 'Should return 5 users for 2 iterations'); }