Пример #1
0
 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);
 }