Example #1
0
 function testCurlWrapperCanDoHttpQueries()
 {
     $curl = new Curl(self::TEST_VALID_URL);
     $curl->setopt(CURLOPT_PROXY, $this->proxy);
     $this->assertTrue($curl->setopt(CURLOPT_RETURNTRANSFER, 1));
     $this->assertTrue($curl->setopt_array(array(CURLOPT_TIMEOUT => self::CURL_TIMEOUT, CURLOPT_FOLLOWLOCATION => true)));
     $result = $curl->exec();
     $this->assertStringStartsWith('<!doctype html>', $result);
     $curl->close();
     $this->assertFalse($curl->hasHandle());
 }
 /**
  *
  * Return case's comments; I assume that there wouldn't be single requests for events of more than 1 case
  * (comments should be show when user clicks on proper button
  * Important: Function is not ready and not used yet.
  * that might be corrected/developed in future
  * 
  * THIS NO WORK !!!
  * THIS NO WORK !!!
  * 
  * @param int $caseID
  */
 public function getComments($caseID)
 {
     $res = 'No comments for this case.';
     $this->resetParams();
     $this->setParam('cmd', 'search');
     $this->setParam('token', $this->token);
     $this->setParam('q', $caseID);
     $this->setParam('cols', 'events');
     $this->curl->setopt_array($this->getCurlOptions());
     $xml = $this->curl->exec();
     if (!empty($xml)) {
         $dom = new DOMDocument();
         $dom->loadXML($xml);
         //$case = $dom->getElementsByTagName( 'case' );
         $events = $dom->getElementsByTagName('event');
         //->item(0)->nodeValue;
         unset($res);
         $res = array();
         foreach ($events as $event) {
             $res[] = array('ixPerson' => $event->getElementsByTagName('ixPerson')->item(0)->nodeValue, 'sPerson' => $event->getElementsByTagName('sPerson')->item(0)->nodeValue, 'ixPersonAssignedTo' => $event->getElementsByTagName('ixPersonAssignedTo')->item(0)->nodeValue, 'dt' => $event->getElementsByTagName('dt')->item(0)->nodeValue, 'evtDescription' => $event->getElementsByTagName('evtDescription')->item(0)->nodeValue, 'sChanges' => $event->getElementsByTagName('sChanges')->item(0)->nodeValue);
         }
     }
     return $res;
 }