Beispiel #1
0
 public function testBeforeSave()
 {
     $this->assertNull($this->status->getCreatedAt());
     $this->status->beforeSave();
     $currentDate = new \DateTime('now', new \DateTimeZone('UTC'));
     $this->assertEquals($currentDate->format('Y-m-d'), $this->status->getCreatedAt()->format('Y-m-d'));
 }
Beispiel #2
0
 /**
  * @param User   $user
  * @param Status $status
  * @param bool   $updateCurrentStatus
  */
 protected function onSuccess(User $user, Status $status, $updateCurrentStatus)
 {
     $status->setUser($user);
     $this->em->persist($status);
     if ($updateCurrentStatus) {
         $user->setCurrentStatus($status);
         $this->um->updateUser($user);
         $this->um->reloadUser($user);
     }
     $this->em->flush();
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $userManager = $this->container->get('oro_user.manager');
     $status1 = new Status();
     $status1->setStatus('status1');
     $manager->persist($status1);
     $this->addReference('status1', $status1);
     $user = $userManager->createUser();
     $user->setUsername('simple_user')->setPlainPassword('simple_password')->setEmail('*****@*****.**')->setFirstName("First Name")->setLastName("Last Name")->setOrganization($organization)->setOrganizations(new ArrayCollection([$organization]))->setOwner($organization->getBusinessUnits()->first())->setEnabled(true);
     $userManager->updateUser($user);
     $this->setReference($user->getUsername(), $user);
 }
Beispiel #4
0
 /**
  * Delete user status
  *
  * @param  User   $user
  * @param  Status $status
  * @param  bool   $reloadUser
  * @return bool
  */
 public function deleteStatus(User $user, Status $status, $reloadUser = true)
 {
     if ($status->getUser() == $user) {
         if ($user->getCurrentStatus() == $status) {
             $user->setCurrentStatus();
             $this->um->updateUser($user);
             if ($reloadUser) {
                 $this->um->reloadUser($user);
             }
         }
         $this->em->remove($status);
         $this->em->flush();
         return true;
     }
     return false;
 }
Beispiel #5
0
 public function testBindValidData()
 {
     $formData = array('status' => 'test status');
     $type = new StatusType();
     $form = $this->factory->create($type);
     $status = new Status();
     $status->setStatus($formData['status']);
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($status, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }