예제 #1
0
 function it_can_serialize(ApiCallInterface $apiCall, DateTime $requestDateTime)
 {
     $duration = 1.23;
     $request = '<request />';
     $response = '<response />';
     $dateTimeFormatted = '1970-01-01T00:00:01+00:00';
     $identity = 'my id';
     $method = 'My::method()';
     $endpoint = 'https://my.endpoint';
     $reference = 'my ref';
     $apiCall->getDuration()->willReturn($duration);
     $apiCall->getRequest()->willReturn($request);
     $apiCall->getResponse()->willReturn($response);
     $requestDateTime->format('c')->willReturn($dateTimeFormatted);
     $apiCall->getRequestDateTime()->willReturn($requestDateTime);
     $apiCall->getId()->willReturn($identity);
     $apiCall->getMethod()->willReturn($method);
     $apiCall->getEndpoint()->willReturn($endpoint);
     $apiCall->getReference()->willReturn($reference);
     $data = json_encode(array('duration' => $duration, 'request' => $request, 'response' => $response));
     $expectedString = sprintf('[%s] (%s) %s (%s) | %s - %s%s', $dateTimeFormatted, $identity, $method, $endpoint, $reference, $data, "\n");
     $this->__invoke($apiCall)->shouldReturn($expectedString);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function __invoke(ApiCallInterface $apiCall)
 {
     $data = json_encode(array('duration' => $apiCall->getDuration(), 'request' => $apiCall->getRequest(), 'response' => $apiCall->getResponse()));
     return sprintf('[%s] (%s) %s (%s) | %s - %s%s', $apiCall->getRequestDateTime()->format('c'), $apiCall->getId(), $apiCall->getMethod(), $apiCall->getEndpoint(), $apiCall->getReference(), $data, $this->eol);
 }