Esempio n. 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());
 }
Esempio n. 2
0
 /**
  * Search tickets
  *
  * @param TicketFilter $query
  * @param int $page
  * @param int $per_page
  * @param null $sort_by
  * @param string $sort_order
  * @return \Dlin\Zendesk\Result\PaginatedResult
  */
 public function search(TicketFilter $query, $page = 1, $per_page = 100, $sort_by = null, $sort_order = 'asc')
 {
     $endPoint = 'search.json?query=' . rawurlencode(implode(' ', $query->toArray()));
     return $this->getCollection($endPoint, 'results', $page, $per_page, $sort_by, $sort_order);
 }