2017 © Pedro Peláez
 

symfony-bundle vcr-bundle

Integrates php-vcr into Symfony and its web profiler.

image

php-vcr/vcr-bundle

Integrates php-vcr into Symfony and its web profiler.

  • Friday, January 19, 2018
  • by K-Phoen
  • Repository
  • 5 Watchers
  • 9 Stars
  • 5,172 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 4 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

VCRBundle

Integrates php-vcr into Symfony and its web profiler. It also provides a VideoRecorderBrowser for testing purpose with extra helper methods handling php-vcr recordings., (*1)

PHP-VCR Symfony web profiler panel PHP-VCR Symfony web profiler panel - request details PHP-VCR Symfony web profiler panel - response details, (*2)

Installation

Install the behavior adding php-vcr/vcr-bundle to your composer.json or from CLI:, (*3)

composer require php-vcr/vcr-bundle

And declare the bundle in your config/bundles.php file:, (*4)

<?php
declare(strict_types = 1);

return [
    // ...
    VCR\VCRBundle\VCRBundle::class => ['test' => true],
];

Usage

Enable the required library hooks for your purpose and write test cases., (*5)

VideoRecorderBrowser (without Trait)

<?php
declare(strict_types = 1);

class ExampleTest extends \VCR\VCRBundle\Tests\Functional\WebTestCase
{
    public function test(): void
    {
        $kernel = static::bootKernel();
        /** @var \VCR\VCRBundle\VideoRecorderBrowser $client */
        $client = $kernel->getContainer()->get('test.client.vcr');

        $client->insertVideoRecorderCassette('my-test-cassette-name');

        // this is an example, normally services inside you project do stuff like this and you trigger them by
        // execute requests via the KernelBrowser client
        file_get_contents('https://www.google.de');

        // cassette.path is configured to '%kernel.project_dir%/tests/Fixtures'
        // recordings are written to %kernel.project_dir%/tests/Fixtures/my-test-cassette-name
        // cassette.path + cassetteName (done by inserting the cassette)
    }
}

VideoRecorderBrowser (with Trait)

<?php
declare(strict_types = 1);

namespace MyCompany\MyProject\Tests\Functional;

class ExampleTest extends \VCR\VCRBundle\Tests\Functional\WebTestCase
{
    use \VCR\VCRBundle\Test\VCRTestCaseTrait;

    /**
     * Specify a namespace prefix which should be ignored while generating the base path for this test case. 
     */
    protected $ignoredTestSuiteNamespacePrefix = 'MyCompany\\MyProject\\Tests\\';

    public function test(): void
    {
        /** @var \VCR\VCRBundle\VideoRecorderBrowser $client */
        $client = static::createVideoRecorderClient();

        // this is an example, normally services inside you project do stuff like this and you trigger them by
        // execute requests via the KernelBrowser client
        file_get_contents('https://www.google.de');

        // cassette.path is configured to '%kernel.project_dir%/tests/Fixtures'
        // recordings are written to %kernel.project_dir%/tests/Fixtures/Functional/ExampleTest/test
        // cassette.path + TestCasePath (- ignoredTestSuiteNamespacePrefix) + TestName
    }
}

Configuration reference

vcr:
  enabled: true
  library_hooks:
    stream_wrapper: false
    curl: false
    soap: false
  request_matchers:
    method: true
    url: true
    query_string: true
    host: true
    headers: true
    body: true
    post_fields: true
  cassette:
    type: json
    path: '%kernel.cache_dir%/vcr'
    name: vcr

Credits

License

This bundle is released under the MIT license., (*6)

The Versions

19/01 2018

dev-master

9999999-dev

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

19/01 2018

1.4.1

1.4.1.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

07/03 2016

1.4.0

1.4.0.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

28/09 2015

1.3.0

1.3.0.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

25/08 2015

1.2.0

1.2.0.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

24/01 2015

1.1.0

1.1.0.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires

 

28/11 2014

1.0.0

1.0.0.0

Integrates php-vcr into Symfony and its web profiler.

  Sources   Download

MIT

The Requires