/** * Returns TRUE when the given Track's request matches the given request. * * @param TrackInterface $track The track. * @param RequestInterface $request The request. * * @return bool TRUE if the Track's request matches the given request, FALSE if not. */ public function matchByRequest(TrackInterface $track, RequestInterface $request) { $trackRequestData = $this->converter->requestToArray($track->getRequest()); $requestData = $this->converter->requestToArray($request); // If the diff is empty, this means that all keys from the Track request are available in the array // from the other request, so they can be considered equal. $diff = $this->array_diff_assoc_recursive($requestData, $trackRequestData); $isEqual = empty($diff); return $isEqual; }
public function testTrackToArrayWithRequestAndResponseAndException() { $array = $this->converter->trackToArray($track = $this->createTrack($this->createRequest(), $this->createResponse(), $this->createException())); $this->assertArrayHasKey('request', $array); $this->assertArrayHasKey('response', $array); $this->assertArrayHasKey('exception', $array); $check = $this->converter->arrayToTrack($array); $this->assertTrue($check->hasResponse()); $this->assertTrue($check->hasException()); }
public function store() { $filePath = $this->getFilePath(); $data = []; foreach ($this->tracks as $track) { $data[] = $this->converter->trackToArray($track); } file_put_contents($filePath, Yaml::dump($data, 4)); }