1. Go to this page and download the library: Download php-vcr/vcr-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
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)
}
}
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
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.