covergenius / phpunit-testlistener-vcr
Integrates PHPUnit with PHP-VCR.
v4.2.1
2024-10-02 00:59 UTC
Requires
- php: ^8.1
- covergenius/php-vcr: ^1.7
- phpunit/phpunit: ^10.4 | ^11
- dev-master
- v4.2.1
- v4.2.0
- v4.1.0
- v4.0.1
- v4.0.0
- v3.x-dev
- v3.3.1
- v3.3.0
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.0
- 2.0.0
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.0
- dev-feature/vcr-attribute
- dev-chore/fix-link-in-readme
- dev-chore/readme-updates
- dev-phpunit10-update
- dev-feature/further-php8-updates
- dev-improvements/php7-love
This package is auto-updated.
Last update: 2024-11-02 01:08:56 UTC
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; use VCR\PHPUnit\TestListener\Attributes\Vcr; 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).'); } #[Vcr('unittest_annotation_test')] public function testInterceptsWithAttributes(): void { // 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 attributes).'); } }
Installation
- Install using composer:
composer require --dev covergenius/phpunit-testlistener-vcr
For phpunit version 10+
- Add listener to your
phpunit.xml
:
<extensions> <bootstrap class="VCR\PHPUnit\TestListener\VCRTestListener" /> </extensions>
For phpunit version 9 and below
<listeners> <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/covergenius/phpunit-testlistener-vcr/src/VCRTestListener.php" /> </listeners>
Dependencies
PHPUnit-Testlistener-VCR depends on the following;
Version 4
- PHP 8.1+
- PHPUnit >=10
Version 3
- PHP 7.1+
- PHPUnit <10
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