コード例 #1
0
ファイル: StateManagerTest.php プロジェクト: Maksold/platform
 public function testGetWidgetStateNew()
 {
     $widget = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Widget');
     $user = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User');
     $this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
     $this->entityManager->expects($this->once())->method('getRepository')->will($this->returnValue($this->repository));
     $this->repository->expects($this->once())->method('findOneBy')->with(array('owner' => $user, 'widget' => $widget))->will($this->returnValue(null));
     $this->entityManager->expects($this->once())->method('persist')->with($this->callback(function ($entity) use($widget, $user) {
         $this->assertInstanceOf('Oro\\Bundle\\DashboardBundle\\Entity\\WidgetState', $entity);
         $this->assertEquals($widget, $entity->getWidget());
         $this->assertEquals($user, $entity->getOwner());
         return true;
     }));
     $this->assertInstanceOf('Oro\\Bundle\\DashboardBundle\\Entity\\WidgetState', $this->stateManager->getWidgetState($widget));
 }
コード例 #2
0
ファイル: Factory.php プロジェクト: Maksold/platform
 /**
  * @param Widget $widget
  * @return WidgetModel
  */
 public function createWidgetModel(Widget $widget)
 {
     $widgetConfig = $this->configProvider->getWidgetConfig($widget->getName());
     $widgetState = $this->stateManager->getWidgetState($widget);
     return new WidgetModel($widget, $widgetConfig, $widgetState);
 }