Skip to content

php-vcr/phpunit-testlistener-vcr

Folders and files

NameName
Last commit message
Last commit date
Jul 3, 2018
Jul 3, 2018
Aug 8, 2017
Jun 22, 2018
Aug 8, 2017
Oct 18, 2016
Jun 22, 2018
Jun 22, 2018
Jun 22, 2018

Repository files navigation

PHPUnit TestListener for PHP-VCR

Integrates PHPUnit with PHP-VCR using annotations.

PHP-VCR

Use @vcr cassette_name on your tests to turn VCR automatically on and off.

Build Status

Usage example

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

Installation

  1. Install using composer:
composer require --dev php-vcr/phpunit-testlistener-vcr
  1. Add listener to your phpunit.xml:
<listeners>
    <listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" />
</listeners>

Dependencies

PHPUnit-Testlistener-VCR depends on:

Run tests

In order to run all tests you need to get development dependencies using composer:

composer install
./vendor/bin/phpunit

Changelog

The changelog is manage at PHPUnit testlistener for PHP-VCR releases page.

Copyright

Copyright (c) 2013-2018 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. Contributors