27 'Authorization' =>
'Baz'
31 $this->response =
new Response(200, array(
35 $this->handle = $this->getMockBuilder(
'Guzzle\Http\Curl\CurlHandle')
36 ->disableOriginalConstructor()
37 ->setMethods(array(
'getError',
'getErrorNo',
'getStderr',
'getInfo'))
40 $this->handle->expects($this->any())
42 ->will($this->returnValue(
'e'));
44 $this->handle->expects($this->any())
45 ->method(
'getErrorNo')
46 ->will($this->returnValue(
'123'));
48 $this->handle->expects($this->any())
50 ->will($this->returnValue(
'testing'));
52 $this->handle->expects($this->any())
54 ->will($this->returnValueMap(array(
55 array(CURLINFO_CONNECT_TIME,
'123'),
56 array(CURLINFO_TOTAL_TIME,
'456')
64 array(
'{method} - {method}',
'POST - POST'),
65 array(
'{url}',
'http://foo.com?q=test'),
66 array(
'{port}',
'80'),
67 array(
'{resource}',
'/?q=test'),
68 array(
'{host}',
'foo.com'),
69 array(
'{hostname}', gethostname()),
70 array(
'{protocol}/{version}',
'HTTP/1.1'),
71 array(
'{code} {phrase}',
'200 OK'),
72 array(
'{req_header_Foo}',
''),
73 array(
'{req_header_X-Foo}',
'bar'),
74 array(
'{req_header_Authorization}',
'Baz'),
75 array(
'{res_header_foo}',
''),
76 array(
'{res_header_X-Test}',
'Abc'),
77 array(
'{req_body}',
'Hello'),
78 array(
'{res_body}',
'Foo'),
79 array(
'{curl_stderr}',
'testing'),
80 array(
'{curl_error}',
'e'),
81 array(
'{curl_code}',
'123'),
82 array(
'{connect_time}',
'123'),
83 array(
'{total_time}',
'456')
93 $this->assertEquals($output, $formatter->format($this->request, $this->response, $this->handle));
99 $formatter->setTemplate(
'{request}{response}');
100 $this->assertEquals($this->request . $this->response, $formatter->format($this->request, $this->response));
106 $this->assertNotEmpty($formatter->format($this->request, $this->response));
112 $response = $this->getMockBuilder(
'Guzzle\Http\Message\Response')
113 ->setConstructorArgs(array(200))
114 ->setMethods(array(
'getInfo'))
118 ->will($this->returnValueMap(array(
119 array(
'connect_time',
'1'),
120 array(
'total_time',
'2'),
122 $this->assertEquals(
'1/2', $formatter->format($this->request,
$response));
128 $this->assertEquals(
'/', $formatter->format($this->request));
136 $log =
new LogPlugin($adapter, $formatter);
137 $this->
getServer()->enqueue(
"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHI");
139 $client->addSubscriber($log);
140 $client->get(
'/')->send();
141 $this->assertNotEquals(
'/', $out);