ivancli / phpunit-testlistener-vcr
将PHPUnit与PHP-VCR集成。
v4.0.1
2024-08-01 00:39 UTC
Requires
- php: ^8.1
- covergenius/php-vcr: ^1.7
- phpunit/phpunit: ^10.4
This package is auto-updated.
Last update: 2024-09-30 02:00:01 UTC
README
使用注解将PHPUnit与PHP-VCR集成。
使用@vcr cassette_name
在你的测试中自动开启和关闭VCR。
用法示例
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).'); } }
安装
- 使用composer安装
composer require --dev covergenius/phpunit-testlistener-vcr
对于phpunit版本10+
- 将监听器添加到你的
phpunit.xml
<extensions> <bootstrap class="VCR\PHPUnit\TestListener\VCRTestListener" /> </extensions>
对于phpunit版本9及以下
<listeners> <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/covergenius/phpunit-testlistener-vcr/src/VCRTestListener.php" /> </listeners>
依赖关系
PHPUnit-Testlistener-VCR依赖于以下:
版本4
- PHP 8.1+
- PHPUnit >=10
版本3
- PHP 7.1+
- PHPUnit <10
运行测试
为了运行所有测试,您需要使用composer获取开发依赖项
composer install ./vendor/bin/phpunit
变更日志
变更日志由PHPUnit testlistener for PHP-VCR发布页面管理。
版权
版权所有 © 2013-2018 Adrian Philipp。在MIT许可的条款下发布。有关详细信息,请参阅LICENSE。 贡献者