Skip to content

Commit d5adfb4

Browse files
bwoodhigidi
authored andcommitted
Spport legacy cassettes. Create a recording index of 0 if no index key exists in the cassette.
1 parent 9037b98 commit d5adfb4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/VCR/Cassette.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public function playback(Request $request, int $index = 0): ?Response
3030
{
3131
foreach ($this->storage as $recording) {
3232
$storedRequest = Request::fromArray($recording['request']);
33+
34+
// Support legacy cassettes which do not have the 'index' key
35+
if (!\array_key_exists('index', $recording)) {
36+
$recording['index'] = 0;
37+
}
38+
3339
if ($index == $recording['index']) {
3440
if ($storedRequest->matches($request, $this->getRequestMatchers())) {
3541
return Response::fromArray($recording['response']);

0 commit comments

Comments
 (0)