datingvip/phpunit-testlistener-vcr

将PHPUnit与PHP-VCR集成。

3.3.0 2021-02-17 21:57 UTC

README

使用注解将PHPUnit与PHP-VCR集成。

PHP-VCR

使用@vcr cassette_name在测试中自动开启和关闭VCR。

Build Status

使用示例

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).');
    }
}

安装

  1. 使用composer安装
composer require --dev php-vcr/phpunit-testlistener-vcr
  1. 将监听器添加到你的phpunit.xml
<listeners>
    <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" />
</listeners>

依赖

PHPUnit-Testlistener-VCR依赖以下

运行测试

为了运行所有测试,你需要使用composer获取开发依赖

composer install
./vendor/bin/phpunit

变更日志

变更日志在PHPUnit testlistener for PHP-VCR发布页面管理。

版权

版权所有(c)2013-2018 Adrian Philipp。在MIT许可证下发布。有关详细信息,请参阅LICENSE。 贡献者