php-vcr / phpunit-testlistener-vcr
Integrates PHPUnit with PHP-VCR.
Installs: 776 621
Dependents: 72
Suggesters: 0
Security: 0
Stars: 60
Watchers: 8
Forks: 50
Open Issues: 7
Requires
- php: ^7.1|^8.0
- php-vcr/php-vcr: ^1.4
Requires (Dev)
- phpunit/phpunit: ^7.0|^8.0
README
Integrates PHPUnit with PHP-VCR using annotations.
Use @vcr cassette_name
on your tests to turn VCR automatically on and off.
Usage example
use PHPUnit\Framework\TestCase; class VCRTest extends 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).'); } }
Installation
- Install using composer:
composer require --dev php-vcr/phpunit-testlistener-vcr
- Add listener to your
phpunit.xml
:
<listeners> <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" /> </listeners>
Dependencies
PHPUnit-Testlistener-VCR depends on:
- PHP 7.1+
- PHP 7.0+ (use <3.0)
- php-vcr/php-vcr
Run tests
In order to run all tests you need to get development dependencies using composer:
composer install ./vendor/bin/phpunit
Changelog
The changelog is manage at PHPUnit testlistener for PHP-VCR releases page.
Copyright
Copyright (c) 2013-2018 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. Contributors