hotrush / phpunit-testlistener-vcr
将PHPUnit与PHP-VCR集成。
3.3.0
2022-11-03 19:39 UTC
Requires
- php: ^8.0
- hotrush/php-vcr: ^1.4
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-08-30 01:49:44 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 php-vcr/phpunit-testlistener-vcr
- 将监听器添加到您的
phpunit.xml
<listeners> <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" /> </listeners>
依赖项
PHPUnit-Testlistener-VCR依赖于
- PHP 7.1+
- PHP 7.0+ (使用 <3.0)
- php-vcr/php-vcr
运行测试
为了运行所有测试,您需要使用composer获取开发依赖项
composer install ./vendor/bin/phpunit
变更日志
变更日志由PHPUnit testlistener for PHP-VCR发布页面管理。
版权
版权所有(c)2013-2018 Adrian Philipp。在MIT许可条款下发布。有关详细信息,请参阅LICENSE。贡献者