public function testBuildLogString()
 {
     $result = 'phpunit-RAWRESULT-FORTESTONLY-phpunit-RAWRESULT-FORTESTONLY-' . mt_rand() . '-phpunit-RAWRESULT-FORTESTONLY';
     $response = new Response();
     $response->create(400, $result);
     $logString = $this->mockTest->buildLogString("http://notexistdomain.com", "a=1", 'POST', $response);
     $this->assertNotEquals(false, strpos($logString, $result));
 }
 public function buildLogString($url, $finalBodyParam, $requestMethod, Response $response)
 {
     $string = '<LOG n="<?php exit;?>">' . PHP_EOL;
     $data = array();
     $data['prefix'] = '<SUMMARY>';
     $data['time'] = gmdate('Y-m-d H:i:s', time() + 28800);
     $data['remoteIp'] = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "CLI";
     $data['response_status'] = $response->isOk() ? 'RESP_OK' : 'RESP_ERR_' . $response->getError();
     $data['http_code'] = $response->getCode();
     $data['requestMethod'] = $requestMethod;
     $data['url'] = $url;
     $data['suffix'] = '</SUMMARY>';
     $string .= implode("\t", $data);
     $string .= PHP_EOL . '<RESP_RAWBODY>' . PHP_EOL;
     $string .= $response->getRawResult();
     $string .= PHP_EOL . '</RESP_RAWBODY>';
     if (null !== $finalBodyParam) {
         $string .= PHP_EOL . '<REQ_BODY>' . PHP_EOL;
         $string .= is_string($finalBodyParam) ? $finalBodyParam : var_export($finalBodyParam, true);
         $string .= PHP_EOL . '</REQ_BODY>';
         $string .= PHP_EOL . '<REQ_BODYTYPE>';
         $string .= is_string($finalBodyParam) ? 'string:application/x-www-form-urlencoded' : 'array:multipart/form-data';
         $string .= '</REQ_BODYTYPE>';
     }
     if (!$response->isOk()) {
         $string .= PHP_EOL . '<RESP_ERROR>';
         $string .= PHP_EOL . var_export($response->getError(true), true);
         $string .= PHP_EOL . '</RESP_ERROR>';
     }
     return $string . PHP_EOL . '</LOG>' . PHP_EOL;
 }