예제 #1
0
 public function testSubmitValidData()
 {
     $formData = ['priority' => TicketMessage::PRIORITY_HIGH, 'message' => null];
     $data = new TicketMessage();
     $data->setPriority(TicketMessage::PRIORITY_HIGH);
     $form = $this->factory->create(method_exists(AbstractType::class, 'getBlockPrefix') ? TicketMessageType::class : new TicketMessageType($this->user), null, ['new_ticket' => true]);
     // submit the data to the form directly
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $formEntity = $form->getData();
     $formEntity->setCreatedAt($data->getCreatedAt());
     $this->assertEquals($data, $formEntity);
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
 public function testSubmitValidData()
 {
     $formData = array('priority' => TicketMessage::PRIORITY_HIGH, 'message' => null);
     $userManager = $this->getMock('Hackzilla\\Bundle\\TicketBundle\\User\\UserInterface');
     $this->assertTrue($userManager instanceof \Hackzilla\Bundle\TicketBundle\User\UserInterface);
     $type = new \Hackzilla\Bundle\TicketBundle\Form\Type\TicketMessageType($userManager, true);
     $data = new \Hackzilla\Bundle\TicketBundle\Entity\TicketMessage();
     $data->setPriority(TicketMessage::PRIORITY_HIGH);
     $form = $this->factory->create($type);
     // submit the data to the form directly
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $formEntity = $form->getData();
     $formEntity->setCreatedAt($data->getCreatedAt());
     $this->assertEquals($data, $formEntity);
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
예제 #3
0
 /**
  * Finds and displays a Ticket entity.
  *
  * @param Ticket $ticket
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Ticket $ticket = null)
 {
     if (!$ticket) {
         return $this->redirect($this->generateUrl('hackzilla_ticket'));
     }
     $userManager = $this->get('hackzilla_ticket.user');
     $this->checkUserPermission($userManager->getCurrentUser(), $ticket);
     $data = array('ticket' => $ticket);
     $message = new TicketMessage();
     $message->setPriority($ticket->getPriority());
     $message->setStatus($ticket->getStatus());
     if (TicketMessage::STATUS_CLOSED != $ticket->getStatus()) {
         $data['form'] = $this->createForm(new TicketMessageType($userManager), $message)->createView();
     }
     if ($this->get('hackzilla_ticket.user')->isGranted($userManager->getCurrentUser(), 'ROLE_TICKET_ADMIN')) {
         $data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();
     }
     return $this->render('HackzillaTicketBundle:Ticket:show.html.twig', $data);
 }
예제 #4
0
 /**
  * Finds and displays a Ticket entity.
  *
  * @param Ticket $ticket
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showAction(Ticket $ticket = null)
 {
     if (!$ticket) {
         return $this->redirect($this->generateUrl('hackzilla_ticket'));
     }
     $userManager = $this->get('hackzilla_ticket.user_manager');
     $this->checkUserPermission($userManager->getCurrentUser(), $ticket);
     $data = ['ticket' => $ticket];
     $message = new TicketMessage();
     $message->setPriority($ticket->getPriority());
     $message->setStatus($ticket->getStatus());
     if (TicketMessage::STATUS_CLOSED != $ticket->getStatus()) {
         $data['form'] = $this->createForm($this->formType(TicketMessageType::class, new TicketMessageType($userManager)), $message, ['new_ticket' => false])->createView();
     }
     if ($userManager->getCurrentUser() && $this->get('hackzilla_ticket.user_manager')->hasRole($userManager->getCurrentUser(), TicketRole::Admin)) {
         $data['delete_form'] = $this->createDeleteForm($ticket->getId())->createView();
     }
     return $this->render('HackzillaTicketBundle:Ticket:show.html.twig', $data);
 }