Beispiel #1
0
 public function testCreateSearchDelete()
 {
     $comment = new TicketComment();
     $comment->setBody('TEST Ticket By David Lin');
     $ticket = new Ticket();
     $ticket->setComment($comment);
     $ticket->setSubject('Test Ticket Subject By David Lin 1');
     $ticket->setTags(array('test'));
     $this->client->save($ticket);
     $ticket = new Ticket();
     $ticket->setComment($comment);
     $ticket->setSubject('Test Ticket Subject By David Lin 2');
     $ticket->setTags(array('test'));
     $this->client->save($ticket);
     $ticket = new Ticket();
     $ticket->setComment($comment);
     $ticket->setSubject('Test Ticket Subject By David Lin 3');
     $ticket->setTags(array('test'));
     $this->client->save($ticket);
     sleep(5);
     //need to wait otherwise not searchable
     $filter = new TicketFilter();
     $filter->setSubject('Test David Lin');
     $searchResult = $this->client->search($filter);
     $count = $searchResult->getCount();
     $this->assertGreaterThanOrEqual(3, $count);
     //delete one
     $item = $searchResult->getItems();
     $this->client->delete($item[0]);
     $searchResult = $this->client->search($filter);
     $newCount = $searchResult->getCount();
     $this->assertEquals(--$count, $newCount);
     $this->client->deleteTickets($searchResult->getItems());
     $this->assertEquals(0, $this->client->search($filter)->getCount());
 }
 public function newAction(Request $request)
 {
     $form = $this->createFormBuilder()->add('mail', 'email', array('constraints' => array(new NotBlank(), new Email())))->add('subject', 'text', array('constraints' => array(new NotBlank())))->add('description', 'textarea', array('constraints' => array(new NotBlank())))->add('submit', 'submit')->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $api = $this->get('dlin.zendesk')->getApi();
         $ticketComment = new TicketComment();
         $ticketComment->setBody($form->get('description')->getData());
         $ticket = new Ticket();
         $ticket->setSubject($form->get('subject')->getData());
         $ticket->setComment($ticketComment);
         $ticketRequester = new TicketRequester();
         $ticketRequester->setEmail($form->get('mail')->getData());
         $ticketRequester->setName($form->get('mail')->getData());
         $ticketClient = new TicketClient($api);
         $result = $ticketClient->save($ticket, $ticketRequester);
         $this->addFlash('notice', 'Votre demande a bien été envoyée !');
         return $this->redirect($this->generateUrl('home'));
     }
     return $this->render('DlinZendeskBundle:Request:request_new.html.twig', array('form' => $form->createView()));
 }
Beispiel #3
0
 /**
  *
  * Delete one given ticket
  *
  * @param Ticket $ticket
  * @return bool
  */
 public function delete(Ticket $ticket)
 {
     return parent::deleteById($ticket->getId(), 'tickets');
 }
Beispiel #4
0
    public function testFromToArray()
    {
        $data = <<<JSON
{
  "id":               35436,
  "url":              "https://company.zendesk.com/api/v2/tickets/35436.json",
  "external_id":      "ahg35h3jh",
  "created_at":       "2009-07-20T22:55:29Z",
  "updated_at":       "2011-05-05T10:38:52Z",
  "type":             "incident",
  "subject":          "Help, my printer is on fire!",
  "description":      "The fire is very colorful.",
  "priority":         "high",
  "status":           "open",
  "recipient":        "*****@*****.**",
  "requester_id":     20978392,
  "submitter_id":     76872,
  "assignee_id":      235323,
  "organization_id":  509974,
  "group_id":         98738,
  "collaborator_ids": [35334, 234],
  "forum_topic_id":   72648221,
  "problem_id":       9873764,
  "has_incidents":    false,
  "due_at":           null,
  "tags":             ["enterprise", "other_tag"],
  "via": {
    "channel": "web"
  },
  "custom_fields": [
    {
      "id":    27642,
      "value": "745"
    },
    {
      "id":    27648,
      "value": "yes"
    }
  ],
  "satisfaction_rating": {
    "id": 1234,
    "score": "good",
    "comment": "Great support!"
  },
  "sharing_agreement_ids": [84432]
}
JSON;
        $data = json_decode($data, true);
        $ticket = new Ticket();
        $ticket->fromArray($data);
        $this->assertEquals($ticket->getId(), 35436);
        $this->assertEquals($ticket->getDescription(), "The fire is very colorful.");
        $this->assertEquals($ticket->getOrganizationId(), 509974);
        $this->assertContains(35334, $ticket->getCollaboratorIds());
        $this->assertContains(234, $ticket->getCollaboratorIds());
        $satisfactionRating = $ticket->getSatisfactionRating();
        $this->assertEquals($satisfactionRating->getId(), 1234);
        $this->assertEquals($satisfactionRating->getScore(), SatisfactionRatingScore::GOOD);
        $this->assertEquals($satisfactionRating->getComment(), "Great support!");
        $this->assertNull($satisfactionRating->getGroupId());
        $this->assertEquals('web', $ticket->getVia()->getChannel());
        $customFields = $ticket->getCustomFields();
        $this->assertCount(2, $ticket->getTags());
        $this->assertCount(1, $ticket->getSharingAgreementIds());
        $this->assertCount(2, $customFields);
        $this->assertEquals($customFields[0]->getId(), 27642);
        $this->assertEquals($customFields[0]->getValue(), "745");
        $this->assertEquals($customFields[1]->getId(), 27648);
        $this->assertEquals($customFields[1]->getValue(), "yes");
        $array = $ticket->toArray();
        $this->assertEquals('https://company.zendesk.com/api/v2/tickets/35436.json', $array['url']);
        $this->assertEquals('web', $array['via']['channel']);
        $this->assertCount(2, $array['custom_fields']);
        $this->assertEquals(27642, $array['custom_fields'][0]['id']);
    }