Skip to content

Commit eea9149

Browse files
committed
Merge pull request #2 from parallax/feature-json-cassette
Support JSON cassettes by passing a filename ending in .json
2 parents 5cce21b + e1b2af3 commit eea9149

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

PHPUnit/Util/Log/VCR.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,21 @@ public function startTest(PHPUnit_Framework_Test $test)
119119
$doc_block = $reflection->getDocComment();
120120

121121
// Use regex to parse the doc_block for a specific annotation
122-
$cassetteName = self::parseDocBlock($doc_block, '@vcr');
122+
$cassetteName = array_pop(self::parseDocBlock($doc_block, '@vcr'));
123+
124+
// If the cassette name ends in .json, then use the JSON storage format
125+
if (substr($cassetteName, '-5') == '.json') {
126+
\VCR\VCR::configure()->setStorage('json');
127+
} else {
128+
\VCR\VCR::configure()->setStorage('yaml');
129+
}
123130

124131
if (empty($cassetteName)) {
125132
return true;
126133
}
127134

128135
\VCR\VCR::turnOn();
129-
\VCR\VCR::insertCassette(array_pop($cassetteName));
136+
\VCR\VCR::insertCassette($cassetteName);
130137
}
131138

132139
private static function parseDocBlock($doc_block, $tag)

0 commit comments

Comments
 (0)