public function testCollect() { $collector1 = $this->getMock('\\Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface'); $nameCollector1 = 'collector1'; $collector1->expects($this->once())->method('getName')->will($this->returnValue($nameCollector1)); $collector2 = $this->getMock('\\Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface'); $nameCollector2 = 'collector2'; $collector2->expects($this->once())->method('getName')->will($this->returnValue($nameCollector2)); $allCollectors = [$nameCollector1 => $collector1, $nameCollector2 => $collector2]; $request = new Request(); $response = new Response(); $exception = new Exception(); /** * @var \PHPUnit_Framework_MockObject_MockObject */ foreach ($allCollectors as $name => $collector) { $this->mainCollector->addCollector($collector); $collector->expects($this->once())->method('collect')->with($request, $response, $exception); } $this->mainCollector->collect($request, $response, $exception); }