Skip to content

Commit

Permalink
Merge pull request #2 from parallax/feature-json-cassette
Browse files Browse the repository at this point in the history
Support JSON cassettes by passing a filename ending in .json
  • Loading branch information
adri committed Oct 23, 2014
2 parents 5cce21b + e1b2af3 commit eea9149
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions PHPUnit/Util/Log/VCR.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,21 @@ public function startTest(PHPUnit_Framework_Test $test)
$doc_block = $reflection->getDocComment();

// Use regex to parse the doc_block for a specific annotation
$cassetteName = self::parseDocBlock($doc_block, '@vcr');
$cassetteName = array_pop(self::parseDocBlock($doc_block, '@vcr'));

// If the cassette name ends in .json, then use the JSON storage format
if (substr($cassetteName, '-5') == '.json') {
\VCR\VCR::configure()->setStorage('json');
} else {
\VCR\VCR::configure()->setStorage('yaml');
}

if (empty($cassetteName)) {
return true;
}

\VCR\VCR::turnOn();
\VCR\VCR::insertCassette(array_pop($cassetteName));
\VCR\VCR::insertCassette($cassetteName);
}

private static function parseDocBlock($doc_block, $tag)
Expand Down

0 comments on commit eea9149

Please sign in to comment.