datingvip / phpunit-testlistener-vcr
将PHPUnit与PHP-VCR集成。
3.3.0
2021-02-17 21:57 UTC
Requires
- php: ^7.1|^8.0
- php-vcr/php-vcr: ^1.4
Requires (Dev)
- phpunit/phpunit: ^7.0|^8.0
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。 贡献者