/** * {@inheritdoc} */ protected function doInitialize() { $widgets = array(); /** @var Widget $widget */ foreach ($this->dashboard->getWidgets() as $widget) { $widgets[] = $this->factory->createWidgetModel($widget); } $this->collection = new ArrayCollection($widgets); }
public function testCreateWidgetModel() { $expectedConfig = array('label' => 'test label'); $name = 'test'; $widget = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Widget'); $widget->expects($this->once())->method('getName')->will($this->returnValue($name)); $this->configProvider->expects($this->once())->method('getWidgetConfig')->with($name)->will($this->returnValue($expectedConfig)); $widgetState = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\WidgetState'); $this->stateManager->expects($this->once())->method('getWidgetState')->with($widget)->will($this->returnValue($widgetState)); $result = $this->dashboardFactory->createWidgetModel($widget); $this->assertEquals($expectedConfig, $result->getConfig()); $this->assertSame($widget, $result->getEntity()); }
/** * Get dashboard widget * * @param Widget $entity * * @return WidgetModel */ public function getWidgetModel(Widget $entity) { return $this->factory->createWidgetModel($entity); }