function it_aggregates_data_from_registered_collectors(DataCollectorInterface $collectorOne, DataCollectorInterface $collectorTwo) { $collectorOne->collect()->willReturn(['data_one' => 'one']); $collectorTwo->collect()->willReturn(['data_two' => 'two', 'data_three' => 'three']); $this->addCollector($collectorOne); $this->addCollector($collectorTwo); $this->collect()->shouldReturn(['data_one' => 'one', 'data_two' => 'two', 'data_three' => 'three']); }
function it_aggregates_data_from_registered_collectors(DataCollectorInterface $collectorOne, DataCollectorInterface $collectorTwo, DataCollectorInterface $collectorThree, DataCollectorInterface $defaultTypeCollector) { $collectorOne->collect()->willReturn(['data_one' => 'one']); $collectorTwo->collect()->willReturn(['data_two' => 'two', 'data_three' => 'three']); $collectorThree->collect()->willReturn(['data_four' => 'four']); $defaultTypeCollector->collect()->willReturn(['data_five' => 'five']); $this->addCollector($collectorOne, 'type1'); $this->addCollector($collectorTwo, 'type2'); $this->addCollector($collectorThree, 'type2'); $this->addCollector($defaultTypeCollector); $this->collect('type1')->shouldReturn(['data_one' => 'one']); $this->collect('type2')->shouldReturn(['data_two' => 'two', 'data_three' => 'three', 'data_four' => 'four']); $this->collect(ChainedDataCollector::DEFAULT_COLLECTOR_TYPE)->shouldReturn(['data_five' => 'five']); }
/** * Return the collected data * * @return JsonResponse */ public function collectAction() { $data = $this->dataCollector->collect(); return new JsonResponse($data); }