Integrates PHPUnit with PHP-VCR using annotations.
Use @vcr cassette_name on your tests to turn VCR automatically on and off.
Using static method calls:
class VCRTest extends \PHPUnit_Framework_TestCase
{
/**
* @vcr unittest_annotation_test
*/
public function testInterceptsWithAnnotations()
{
// Content of tests/fixtures/unittest_annotation_test: "This is a annotation test dummy".
$result = file_get_contents('http://google.com');
$this->assertEquals('This is a annotation test dummy.', $result, 'Call was not intercepted (using annotations).');
}
}- Add to your
composer.json:
"require-dev": {
"adri/phpunit-testlistener-vcr": "*"
}- Install using composer:
composer install --dev- Add listener to your
phpunit.xml:
<listeners>
<listener class="PHPUnit_Util_Log_VCR" file="PHPUnit/Util/Log/VCR.php"></listener>
</listeners>PHPUnit-Testlistener-VCR depends on:
- PHP 5.3+
- adri/php-vcr
In order to run all tests you need to get development dependencies using composer:
composer install --dev
phpunit ./tests- 2013-05-14 version 0.1: First prototype
Copyright (c) 2013 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details.
