Esempio n. 1
0
 /**
  * @dataProvider addWidgetRecalculatePositionDataProvider
  */
 public function testAddWidgetMinColumnPosition(array $layoutPositions, $column, array $expectedLayoutPosition)
 {
     $widgetEntity = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Widget');
     $widgetModel = $this->getMockBuilder('Oro\\Bundle\\DashboardBundle\\Model\\WidgetModel')->disableOriginalConstructor()->getMock();
     $widgetModel->expects($this->once())->method('getEntity')->will($this->returnValue($widgetEntity));
     $widgetModel->expects($this->once())->method('setLayoutPosition')->with($expectedLayoutPosition);
     $this->dashboardEntity->expects($this->once())->method('addWidget')->with($widgetEntity);
     foreach ($layoutPositions as $index => $layoutPosition) {
         $this->widgets[$index]->expects($this->once())->method('getLayoutPosition')->will($this->returnValue($layoutPosition));
     }
     $this->dashboardModel->addWidget($widgetModel, $column);
     $this->assertEquals($widgetModel, $this->widgets[2]);
 }
Esempio n. 2
0
 /**
  * Copy widgets from source entity to dashboard model
  *
  * @param DashboardModel $target
  * @param Dashboard      $source
  */
 protected function copyWidgets(DashboardModel $target, Dashboard $source)
 {
     foreach ($source->getWidgets() as $sourceWidget) {
         $widgetModel = $this->copyWidgetModel($sourceWidget);
         $this->save($widgetModel, false);
         $target->addWidget($widgetModel);
     }
 }