public function testSetAndGetUser() { $expected = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\User'); $this->activeDashboard->setUser($expected); $this->assertSame($expected, $this->activeDashboard->getUser()); }
/** * Set current dashboard as active for passed user * * @param DashboardModel $dashboard * @param User $user * @param bool $flush * * @return bool */ public function setUserActiveDashboard(DashboardModel $dashboard, User $user, $flush = false) { /** @var OrganizationContextTokenInterface $token */ $token = $this->securityContext->getToken(); $organization = $token->getOrganizationContext(); $activeDashboard = $this->entityManager->getRepository('OroDashboardBundle:ActiveDashboard')->findOneBy(array('user' => $user, 'organization' => $organization)); if (!$activeDashboard) { $activeDashboard = new ActiveDashboard(); $activeDashboard->setUser($user); $activeDashboard->setOrganization($organization); $this->entityManager->persist($activeDashboard); } $entity = $dashboard->getEntity(); $activeDashboard->setDashboard($entity); if ($flush) { $this->entityManager->flush($activeDashboard); } }