/**
  * Test ticket by id method => uses tickets.json data
  */
 public function testSingleTicket()
 {
     $ticket = new TicketM($this->data->singleTicket);
     $target = new TicketM(array('displayId' => $ticket->getDisplayId()));
     $this->restMock->method('restCall')->willReturn(json_encode($this->data->singleTicket));
     $this->restMock->getTicketById($target->getDisplayId(), $target);
     $this->assertTrue(count($ticket->getNotes()) === count($target->getNotes()));
     $this->assertEquals($ticket, $target);
     $this->assertTrue($ticket->getDescription() === $target->getDescription());
     $this->assertTrue($ticket->getSubject() === $target->getSubject());
     $this->assertTrue($ticket->getStatus() === $target->getStatus());
     $this->assertTrue($ticket->getStatusName() === $target->getStatusName());
     $this->assertTrue($ticket->getId() === $target->getId());
     $this->assertTrue($ticket->getDeleted() === $target->getDeleted());
     $this->assertEquals($ticket->toJsonData(), $target->toJsonData());
     if ($ticket->getNotes()) {
         $this->assertNotEmpty($target->getNotes());
         $expected = $ticket->getNotes();
         $notes = $target->getNotes();
         /** @var Freshdesk\Model\Note $note */
         foreach ($notes as $k => $note) {
             $this->assertInstanceOf(get_class($expected[$k]), $note);
             $this->assertTrue($expected[$k]->getDeleted() === $note->getDeleted());
             $this->assertEquals($expected[$k]->toJsonData(), $note->toJsonData());
         }
     }
 }
 /**
  * Assign given ticket to responder by id
  * @param TicketM $ticket
  * @param int $responder
  * @return TicketM
  * @throws \InvalidArgumentException
  */
 public function assignTicket(TicketM $ticket, $responder)
 {
     if (!is_numeric($responder) || $responder < 1) {
         throw new \InvalidArgumentException(sprintf('Failed to assign ticket #%d to "%s", responder must be a positive numeric value', $ticket->getDisplayId(), $responder));
     }
     $url = sprintf('/helpdesk/tickets/%d/assign.json?responder_id=%d', $ticket->getDisplayId(), (int) $responder);
     $response = json_decode($this->restCall($url, self::METHOD_PUT));
     if (is_array($response)) {
         //again, the docs on freshdesk.com/api are unclear. This call seems to be returning an array
         $response = $response[0];
     }
     return $ticket->setAll($response);
 }