/**
  * @param array $data
  *
  * @return TrackInterface
  */
 public function arrayToTrack(array $data)
 {
     $track = new Track($this->arrayToRequest($data['request']));
     if (isset($data['response'])) {
         $track->setResponse($this->arrayToResponse($data['response']));
     }
     if (isset($data['exception'])) {
         $track->setException($this->arrayToException($data['exception']));
     }
     return $track;
 }
 /**
  * Creates a track.
  *
  * @param RequestInterface     $request
  * @param ResponseInterface    $response
  * @param HttpAdapterException $exception
  *
  * @return Track
  */
 protected function createTrack(RequestInterface $request = null, ResponseInterface $response = null, HttpAdapterException $exception = null)
 {
     $request = $request ?: $this->createRequest();
     $track = new Track($request);
     if ($response) {
         $track->setResponse($response);
     }
     if ($exception) {
         $track->setException($exception);
     }
     return $track;
 }
 private function prepareFixtureFile($methodName)
 {
     $tape = $this->createTape($methodName);
     $httpAdapter = HttpAdapterFactory::guess();
     $request = $httpAdapter->getConfiguration()->getMessageFactory()->createRequest('http://httpstat.us/200');
     $response = $httpAdapter->sendRequest($request);
     $exception = new HttpAdapterException();
     $exception->setRequest($httpAdapter->getConfiguration()->getMessageFactory()->createInternalRequest('http://httpstat.us/200'));
     $exception->setResponse($response);
     $track = new Track($request);
     $track->setResponse($response);
     $track->setException($exception);
     $tape->writeTrack($track);
     $tape->store();
 }
 public function testSetException()
 {
     $this->track->setException($exception = $this->createExceptionMock());
     $this->assertTrue($this->track->hasException());
     $this->assertSame($exception, $this->track->getException());
 }