コード例 #1
0
 public function testDelete()
 {
     $dashboard = $this->dashboardManager->findOneDashboardModelBy(['name' => 'main']);
     $this->assertNotNull($dashboard);
     $this->client->request('DELETE', $this->getUrl('oro_api_delete_dashboard', ['id' => $dashboard->getId()]), [], [], $this->generateWsseAuthHeader(LoadUserData::USER_NAME, LoadUserData::USER_PASSWORD));
     $result = $this->client->getResponse();
     $this->assertJsonResponseStatusCodeEquals($result, 403);
     $this->assertNotNull($dashboard);
 }
コード例 #2
0
 public function testPut()
 {
     $data = ['isExpanded' => 1, 'layoutPosition' => [2, 20]];
     $this->client->request('PUT', $this->getUrl('oro_api_put_dashboard_widget', ['dashboardId' => $this->widget->getDashboard()->getId(), 'widgetId' => $this->widget->getId()]), $data);
     $result = $this->client->getResponse();
     $this->assertEmptyResponseStatusCodeEquals($result, 204);
     $this->em->refresh($this->widget);
     $model = $this->dashboardManager->findWidgetModel($this->widget->getId());
     $this->assertEquals($data['isExpanded'], $model->isExpanded());
     $this->assertEquals($data['layoutPosition'], $this->widget->getLayoutPosition());
     $this->assertEquals($data['layoutPosition'], $model->getLayoutPosition());
 }
コード例 #3
0
 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     $dashboardTab = $event->getMenu()->getChild('dashboard_tab');
     if (!$dashboardTab || !$this->securityFacade->hasLoggedUser()) {
         return;
     }
     $dashboards = $this->manager->findAllowedDashboards();
     if (count($dashboards) > 0) {
         foreach ($dashboards as $dashboard) {
             $dashboardId = $dashboard->getId();
             $dashboardLabel = $dashboard->getLabel();
             $dashboardLabel = strlen($dashboardLabel) > 50 ? substr($dashboardLabel, 0, 50) . '...' : $dashboardLabel;
             $options = array('label' => $dashboardLabel, 'route' => 'oro_dashboard_view', 'extras' => array('position' => 1), 'routeParameters' => array('id' => $dashboardId, 'change_dashboard' => true));
             $dashboardTab->addChild($dashboardId . '_dashboard_menu_item', $options)->setAttribute('data-menu', $dashboardId);
         }
         $dashboardTab->addChild('divider-' . rand(1, 99999))->setLabel('')->setAttribute('class', 'divider menu-divider')->setExtra('position', 2);
     }
 }
コード例 #4
0
ファイル: ManagerTest.php プロジェクト: Maksold/platform
 public function testSetUserActiveDashboardCreateNew()
 {
     $dashboard = $this->getMock('Oro\\Bundle\\DashboardBundle\\Entity\\Dashboard');
     $dashboardModel = $this->getMockBuilder('Oro\\Bundle\\DashboardBundle\\Model\\DashboardModel')->disableOriginalConstructor()->getMock();
     $dashboardModel->expects($this->once())->method('getEntity')->will($this->returnValue($dashboard));
     $user = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User');
     $organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
     $token = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Authentication\\Token\\UsernamePasswordOrganizationToken')->disableOriginalConstructor()->getMock();
     $this->securityContext->expects($this->once())->method('getToken')->will($this->returnValue($token));
     $token->expects($this->once())->method('getOrganizationContext')->will($this->returnValue($organization));
     $this->activeDashboardRepository->expects($this->once())->method('findOneBy')->with(array('user' => $user, 'organization' => $organization))->will($this->returnValue(null));
     $this->entityManager->expects($this->once())->method('persist');
     $this->entityManager->expects($this->once())->method('flush')->with($this->isInstanceOf('Oro\\Bundle\\DashboardBundle\\Entity\\ActiveDashboard'));
     $this->manager->setUserActiveDashboard($dashboardModel, $user, true);
 }
コード例 #5
0
 /**
  * @return Dashboard
  */
 protected function getChoices()
 {
     return array_map(function (DashboardModel $dashboardModel) {
         return $dashboardModel->getEntity();
     }, $this->manager->findAllowedDashboards());
 }