Skip to content

Commit 074fb85

Browse files
bwoodhigidi
authored andcommitted
Add testPlaybackLegacyCassette() to ensure that legacy cassettes with no index keys playback.
1 parent edb27bd commit 074fb85

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/Unit/CassetteTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,26 @@ public function testHasResponseFound(): void
6262

6363
$this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.');
6464
}
65+
66+
/**
67+
* Test playback of a legacy cassette which does not have an index key.
68+
*/
69+
public function testPlaybackLegacyCassette(): void
70+
{
71+
$request = new Request('GET', 'https://example.com');
72+
$response = new Response(200, [], 'sometest');
73+
74+
// Create recording array with no index key.
75+
$recording = [
76+
'request' => $request->toArray(),
77+
'response' => $response->toArray(),
78+
];
79+
80+
$storage = new Storage\Yaml(vfsStream::url('test/'), 'json_test');
81+
$storage->storeRecording($recording);
82+
$configuration = new Configuration();
83+
$cassette = new Cassette('cassette_name', $configuration, $storage);
84+
85+
$this->assertEquals($response->toArray(), $cassette->playback($request)->toArray());
86+
}
6587
}

0 commit comments

Comments
 (0)