php-vcr/phpunit-testlistener-vcr

Integrates PHPUnit with PHP-VCR.

Installs: 24 215

Dependents: 16

Stars: 7

Watchers: 4

Forks: 5

Language: PHP

1.1.5 2014-10-29 08:16 UTC

README

Integrates PHPUnit with PHP-VCR using annotations.

PHP-VCR

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

Usage example

class VCRTest extends \PHPUnit_Framework_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) Add to your composer.json:

    "require-dev": {
        "php-vcr/phpunit-testlistener-vcr": "*"
    }

2) Install using composer:

composer require --dev php-vcr/phpunit-testlistener-vcr

3) Add listener to your phpunit.xml:

   <listeners>
      <listener class="PHPUnit_Util_Log_VCR" file="vendor/php-vcr/phpunit-testlistener-vcr/PHPUnit/Util/Log/VCR.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 --dev
phpunit ./tests

Changelog

  • 2013-05-14 1.0.0: First prototype

Copyright

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