covergenius / phpunit-testlistener-vcr
将 PHPUnit 与 PHP-VCR 集成。
v4.1.0
2024-08-01 01:56 UTC
Requires
- php: ^8.1
- covergenius/php-vcr: ^1.7
- phpunit/phpunit: ^10.4 | ^11
- dev-master
- 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-09-20 04:20:26 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。 贡献者