From e1250a11ac185f5606e05df52ebeb998689ffc84 Mon Sep 17 00:00:00 2001 From: Vova Stolyarchuk <41348702+cb-vova@users.noreply.github.com> Date: Tue, 15 Jul 2025 17:30:34 +0300 Subject: [PATCH] feat: separate cassettes per dataProvider cases --- README.md | 168 +++++++++++++++++- src/Subscribers/AttributeResolverTrait.php | 46 ++--- src/Subscribers/StartRecording.php | 34 +++- src/UseCassette.php | 9 +- src/Values/TestCaseParameters.php | 16 ++ src/Values/TestMethodInfo.php | 34 ++++ ...SeparateCassettesInSeparateFoldersTest.php | 58 ++++++ ...ithSeparateCassettesInSingleFolderTest.php | 54 ++++++ tests/AttributeDeclaredOnMethodsTest.php | 55 ++++++ tests/WithoutVcrTest.php | 18 ++ tests/fixtures/on_methods_without_extension | 24 +++ .../example-com | 24 +++ .../example-org | 24 +++ .../test-case-with-spaces | 24 +++ ...er_and_separated_cassettes-example-com.yml | 24 +++ ...er_and_separated_cassettes-example-org.yml | 24 +++ ...arated_cassettes-test-case-with-spaces.yml | 24 +++ .../0.yml | 24 +++ .../1.yml | 24 +++ .../on_class.yml | 24 +++ .../on_class/0.yml | 24 +++ .../on_class/1.yml | 24 +++ .../on_class/example-com.yml | 24 +++ .../on_class/example-org.yml | 24 +++ .../on_class-0.yml | 24 +++ .../on_class-1.yml | 24 +++ .../on_class-example-com.yml | 24 +++ .../on_class-example-org.yml | 24 +++ .../on_class.yml | 24 +++ 29 files changed, 920 insertions(+), 28 deletions(-) create mode 100644 src/Values/TestCaseParameters.php create mode 100644 src/Values/TestMethodInfo.php create mode 100644 tests/AttributeDeclaredOnClassWithSeparateCassettesInSeparateFoldersTest.php create mode 100644 tests/AttributeDeclaredOnClassWithSeparateCassettesInSingleFolderTest.php create mode 100644 tests/WithoutVcrTest.php create mode 100644 tests/fixtures/on_methods_without_extension create mode 100644 tests/fixtures/on_methods_without_extension_with_data_provider/example-com create mode 100644 tests/fixtures/on_methods_without_extension_with_data_provider/example-org create mode 100644 tests/fixtures/on_methods_without_extension_with_data_provider/test-case-with-spaces create mode 100644 tests/fixtures/with_data_provider_and_separated_cassettes-example-com.yml create mode 100644 tests/fixtures/with_data_provider_and_separated_cassettes-example-org.yml create mode 100644 tests/fixtures/with_data_provider_and_separated_cassettes-test-case-with-spaces.yml create mode 100644 tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/0.yml create mode 100644 tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/1.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_separated_folders/on_class.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/0.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/1.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-com.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-org.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_single_folder/on_class-0.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_single_folder/on_class-1.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-com.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-org.yml create mode 100644 tests/fixtures/with_separate_cassettes_in_single_folder/on_class.yml diff --git a/README.md b/README.md index 0b6575b..478fd74 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ Then, add the extension to your PHPUnit configuration file. ## Usage The library provides an `UseCassette` attribute that can be declared on test classes or specific test methods. The -attribute expects one string argument - the name of the cassette. +attribute accepts a cassette name and optional parameters for advanced functionality like separate cassettes per +data provider case. When running the tests, the library will automatically turn the recorder on and off, and insert the cassettes when needed. @@ -54,7 +55,7 @@ responses in the given cassette. { #[Test] public function example(): void { ... } - + #[Test] public function another(): void { ... } } @@ -102,4 +103,165 @@ used for that method. In this example, the responses from the requests made in t #[UseCassette("example_2.yml")] public function recorded(): void { ... } } - ``` \ No newline at end of file + ``` + +## DataProvider Support + +The library supports PHPUnit's `DataProvider` functionality with additional options for managing cassettes when using data providers. + +### Basic DataProvider Usage + +When using a data provider with the basic `UseCassette` attribute, all test cases from the data provider will share the same cassette file: + +```php +use Angelov\PHPUnitPHPVcr\UseCassette; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\TestCase; + +class ExampleTest extends TestCase +{ + #[Test] + #[UseCassette("shared_cassette.yml")] + #[DataProvider("urls")] + public function testWithDataProvider(string $url): void + { + $content = file_get_contents($url); + // All test cases will use the same cassette file + } + + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } +} +``` + +### Separate Cassettes Per DataProvider Case + +For more granular control, you can create separate cassette files for each data provider case using the `separateCassettePerCase` parameter: + +```php +use Angelov\PHPUnitPHPVcr\UseCassette; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\TestCase; + +class ExampleTest extends TestCase +{ + #[Test] + #[UseCassette(name: "separate_cassettes.yml", separateCassettePerCase: true)] + #[DataProvider("urls")] + public function testWithSeparateCassettes(string $url): void + { + $content = file_get_contents($url); + // Each test case will have its own cassette file: + // - separate_cassettes-0.yml + // - separate_cassettes-1.yml + } + + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } +} +``` + +### Named DataProvider Cases + +When using named data provider cases, the cassette files will use the case names: + +```php +use Angelov\PHPUnitPHPVcr\UseCassette; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\TestCase; + +class ExampleTest extends TestCase +{ + #[Test] + #[UseCassette(name: "named_cassettes.yml", separateCassettePerCase: true)] + #[DataProvider("namedUrls")] + public function testWithNamedCassettes(string $url): void + { + $content = file_get_contents($url); + // Each test case will have its own cassette file: + // - named_cassettes-example-com.yml + // - named_cassettes-example-org.yml + } + + public static function namedUrls(): iterable + { + yield 'example.com' => ["https://example.com"]; + yield 'example.org' => ["https://example.org"]; + } +} +``` + +### Grouping Cassettes in Directories + +To organize separate cassette files in directories, use the `groupCaseFilesInDirectory` parameter: + +```php +use Angelov\PHPUnitPHPVcr\UseCassette; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\TestCase; + +class ExampleTest extends TestCase +{ + #[Test] + #[UseCassette( + name: "organized_cassettes.yml", + separateCassettePerCase: true, + groupCaseFilesInDirectory: true + )] + #[DataProvider("urls")] + public function testWithOrganizedCassettes(string $url): void + { + $content = file_get_contents($url); + // Cassette files will be organized in a directory: + // - organized_cassettes/0.yml + // - organized_cassettes/1.yml + } + + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } +} +``` + +### Class-Level DataProvider Support + +The dataProvider functionality also works when the `UseCassette` attribute is declared at the class level: + +```php +use Angelov\PHPUnitPHPVcr\UseCassette; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\TestCase; + +#[UseCassette(name: "class_level.yml", separateCassettePerCase: true)] +class ExampleTest extends TestCase +{ + #[Test] + #[DataProvider("urls")] + public function testMethod(string $url): void + { + $content = file_get_contents($url); + // Each test case will have separate cassettes: + // - class_level-0.yml + // - class_level-1.yml + } + + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } +} +``` diff --git a/src/Subscribers/AttributeResolverTrait.php b/src/Subscribers/AttributeResolverTrait.php index 556f7a4..6dfa314 100644 --- a/src/Subscribers/AttributeResolverTrait.php +++ b/src/Subscribers/AttributeResolverTrait.php @@ -5,6 +5,8 @@ namespace Angelov\PHPUnitPHPVcr\Subscribers; use Angelov\PHPUnitPHPVcr\UseCassette; +use Angelov\PHPUnitPHPVcr\Values\TestCaseParameters; +use Angelov\PHPUnitPHPVcr\Values\TestMethodInfo; use Exception; use ReflectionMethod; @@ -12,52 +14,56 @@ trait AttributeResolverTrait { private function needsRecording(string $test): bool { - return $this->getAttribute($test) !== null; + return $this->getTestCaseCassetteParameters($test) !== null; } - private function getCassetteName(string $test): ?string + private function getTestCaseCassetteParameters(string $test): ?TestCaseParameters { - return $this->getAttribute($test)?->name; - } - - private function getAttribute(string $test): ?UseCassette - { - $test = $this->parseMethod($test); + $testMethodDetails = $this->parseMethod($test); try { if (PHP_VERSION_ID < 80300) { - $method = new ReflectionMethod($test); + $method = new ReflectionMethod($testMethodDetails->method); } else { // @phpstan-ignore-next-line - $method = ReflectionMethod::createFromMethodName($test); + $method = ReflectionMethod::createFromMethodName($testMethodDetails->method); } } catch (Exception) { return null; } - $attributes = $method->getAttributes(UseCassette::class); + $cassetteAttribute = $method->getAttributes(UseCassette::class); - if ($attributes) { - return $attributes[0]->newInstance(); + $cassetteAttributeInstance = $cassetteAttribute + ? $cassetteAttribute[0]->newInstance() : $this->getAttributeFromClass($testMethodDetails); + + if ($cassetteAttributeInstance === null) { + return null; } - return $this->getAttributeFromClass($test); + return new TestCaseParameters( + cassetteInfo: $cassetteAttributeInstance, + case: $testMethodDetails->dataProvider, + ); } - private function parseMethod(string $test): string + private function parseMethod(string $test): TestMethodInfo { - $test = explode(" ", $test)[0]; + $methodDetails = explode("#", $test); - return explode("#", $test)[0]; + return new TestMethodInfo( + method: $methodDetails[0], + dataProvider: $methodDetails[1] ?? null + ); } - private function getAttributeFromClass(string $test): ?UseCassette + private function getAttributeFromClass(TestMethodInfo $test): ?UseCassette { if (PHP_VERSION_ID < 80300) { - $method = new ReflectionMethod($test); + $method = new ReflectionMethod($test->method); } else { // @phpstan-ignore-next-line - $method = ReflectionMethod::createFromMethodName($test); + $method = ReflectionMethod::createFromMethodName($test->method); } $class = $method->getDeclaringClass(); $attributes = $class->getAttributes(UseCassette::class); diff --git a/src/Subscribers/StartRecording.php b/src/Subscribers/StartRecording.php index 049341f..0bacf6e 100644 --- a/src/Subscribers/StartRecording.php +++ b/src/Subscribers/StartRecording.php @@ -4,6 +4,8 @@ namespace Angelov\PHPUnitPHPVcr\Subscribers; +use Angelov\PHPUnitPHPVcr\UseCassette; +use Angelov\PHPUnitPHPVcr\Values\TestCaseParameters; use PHPUnit\Event\Test\Prepared; use PHPUnit\Event\Test\PreparedSubscriber; use VCR\VCR; @@ -20,10 +22,38 @@ public function notify(Prepared $event): void return; } - $cassetteName = $this->getCassetteName($test); - assert($cassetteName !== null); + $testCaseCassetteParameters = $this->getTestCaseCassetteParameters($test); + assert($testCaseCassetteParameters instanceof TestCaseParameters); + + if ($testCaseCassetteParameters->case !== null) { + $cassetteName = $this->makeCassetteNameForCase( + case: $testCaseCassetteParameters->case, + cassetteInfo: $testCaseCassetteParameters->cassetteInfo, + ); + } else { + $cassetteName = $testCaseCassetteParameters->cassetteInfo->name; + } VCR::turnOn(); VCR::insertCassette($cassetteName); } + + private function makeCassetteNameForCase(string $case, UseCassette $cassetteInfo): string + { + if (!$cassetteInfo->separateCassettePerCase) { + return $cassetteInfo->name; + } + + $cassetteNameParts = explode('.', $cassetteInfo->name); + $cassetteSuffix = $cassetteInfo->groupCaseFilesInDirectory ? '/' . $case : '-' . $case; + + if (count($cassetteNameParts) === 1) { + //the cassette name does not contain a dot, so we can use it as is + return $cassetteInfo->name . $cassetteSuffix; + } + + $ext = array_pop($cassetteNameParts); + + return implode('.', $cassetteNameParts) . $cassetteSuffix . '.' . $ext; + } } diff --git a/src/UseCassette.php b/src/UseCassette.php index 0474b70..59e904a 100644 --- a/src/UseCassette.php +++ b/src/UseCassette.php @@ -7,9 +7,12 @@ use Attribute; #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)] -class UseCassette +readonly class UseCassette { - public function __construct(public readonly string $name) - { + public function __construct( + public string $name, + public bool $separateCassettePerCase = false, + public bool $groupCaseFilesInDirectory = false + ) { } } diff --git a/src/Values/TestCaseParameters.php b/src/Values/TestCaseParameters.php new file mode 100644 index 0000000..4118e59 --- /dev/null +++ b/src/Values/TestCaseParameters.php @@ -0,0 +1,16 @@ +dataProvider = $this->normaliseDataProvider($dataProvider); + } + + private function normaliseDataProvider(?string $dataProvider): ?string + { + if ($dataProvider === null) { + return null; + } + + $replaced = (string)preg_replace('/-+/', '-', (string)preg_replace('/\W+/', '-', $dataProvider)); + + if ($replaced === '') { + throw new InvalidArgumentException('Invalid data provider name: ' . $dataProvider); + } + + return trim(strtolower($replaced)); + } +} diff --git a/tests/AttributeDeclaredOnClassWithSeparateCassettesInSeparateFoldersTest.php b/tests/AttributeDeclaredOnClassWithSeparateCassettesInSeparateFoldersTest.php new file mode 100644 index 0000000..ce8dbcb --- /dev/null +++ b/tests/AttributeDeclaredOnClassWithSeparateCassettesInSeparateFoldersTest.php @@ -0,0 +1,58 @@ +assertSame("Example body for \"https://example.com\" without data provider", $content); + } + + #[Test] + #[DataProvider("urls")] + public function it_uses_vcr_on_methods_with_data_provider(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\" with numeric urls", $url), $content); + } + + #[Test] + #[DataProvider("namedUrls")] + public function it_uses_vcr_on_methods_with_data_provider_named_use_cases(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\" with named urls", $url), $content); + } + + /** @return iterable> */ + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } + + /** @return iterable> */ + public static function namedUrls(): iterable + { + yield 'example.com' => ["https://example.com"]; + yield 'example.org' => ["https://example.org"]; + } +} diff --git a/tests/AttributeDeclaredOnClassWithSeparateCassettesInSingleFolderTest.php b/tests/AttributeDeclaredOnClassWithSeparateCassettesInSingleFolderTest.php new file mode 100644 index 0000000..26026c8 --- /dev/null +++ b/tests/AttributeDeclaredOnClassWithSeparateCassettesInSingleFolderTest.php @@ -0,0 +1,54 @@ +assertSame("Example body for \"https://example.com\"", $content); + } + + #[Test] + #[DataProvider("urls")] + public function it_uses_vcr_on_methods_with_data_provider(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); + } + + #[Test] + #[DataProvider("namedUrls")] + public function it_uses_vcr_on_methods_with_data_provider_named_use_cases(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); + } + + /** @return iterable> */ + public static function urls(): iterable + { + yield ["https://example.com"]; + yield ["https://example.org"]; + } + + /** @return iterable> */ + public static function namedUrls(): iterable + { + yield 'example.com' => ["https://example.com"]; + yield 'example.org' => ["https://example.org"]; + } +} diff --git a/tests/AttributeDeclaredOnMethodsTest.php b/tests/AttributeDeclaredOnMethodsTest.php index 12673a2..fd8f4f1 100644 --- a/tests/AttributeDeclaredOnMethodsTest.php +++ b/tests/AttributeDeclaredOnMethodsTest.php @@ -20,6 +20,29 @@ public function it_uses_vcr_on_methods_with_attribute(): void $this->assertSame("Example body.", $content); } + #[Test] + #[UseCassette("on_methods_without_extension")] + public function it_uses_vcr_on_methods_with_attribute_cassette_without_extension(): void + { + $content = file_get_contents("https://example.com"); + + $this->assertSame("Example body.", $content); + } + + #[Test] + #[UseCassette( + name: "on_methods_without_extension_with_data_provider", + separateCassettePerCase: true, + groupCaseFilesInDirectory:true, + )] + #[DataProvider("namedUrls")] + public function it_uses_vcr_on_methods_with_attribute_cassette_and_data_provider_without_extension(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); + } + #[Test] #[UseCassette("with_data_provider.yml")] #[DataProvider("urls")] @@ -30,10 +53,42 @@ public function it_uses_vcr_on_methods_with_data_provider(string $url): void $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); } + #[Test] + #[UseCassette(name: "with_data_provider_and_separated_cassettes.yml", separateCassettePerCase: true)] + #[DataProvider("namedUrls")] + public function it_uses_vcr_on_methods_with_data_provider_and_separate_cassette_per_case(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); + } + + #[Test] + #[UseCassette( + name: "with_data_provider_and_separated_cassettes_in_directory.yml", + separateCassettePerCase: true, + groupCaseFilesInDirectory: true, + )] + #[DataProvider("urls")] + public function it_uses_vcr_on_methods_with_data_provider_and_separate_cassette_per_case_in_directories(string $url): void + { + $content = file_get_contents($url); + + $this->assertSame(sprintf("Example body for \"%s\"", $url), $content); + } + /** @return iterable> */ public static function urls(): iterable { yield ["https://example.com"]; yield ["https://example.org"]; } + + /** @return iterable> */ + public static function namedUrls(): iterable + { + yield 'example.com' => ["https://example.com"]; + yield 'example.org' => ["https://example.org"]; + yield 'test case with spaces' => ["https://example.org"]; + } } diff --git a/tests/WithoutVcrTest.php b/tests/WithoutVcrTest.php new file mode 100644 index 0000000..34a1af0 --- /dev/null +++ b/tests/WithoutVcrTest.php @@ -0,0 +1,18 @@ +assertTrue(true); + } +} diff --git a/tests/fixtures/on_methods_without_extension b/tests/fixtures/on_methods_without_extension new file mode 100644 index 0000000..c2ca2dc --- /dev/null +++ b/tests/fixtures/on_methods_without_extension @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '454479' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:07:20 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:07:20 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body." + index: 0 diff --git a/tests/fixtures/on_methods_without_extension_with_data_provider/example-com b/tests/fixtures/on_methods_without_extension_with_data_provider/example-com new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/on_methods_without_extension_with_data_provider/example-com @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0 diff --git a/tests/fixtures/on_methods_without_extension_with_data_provider/example-org b/tests/fixtures/on_methods_without_extension_with_data_provider/example-org new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/on_methods_without_extension_with_data_provider/example-org @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/on_methods_without_extension_with_data_provider/test-case-with-spaces b/tests/fixtures/on_methods_without_extension_with_data_provider/test-case-with-spaces new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/on_methods_without_extension_with_data_provider/test-case-with-spaces @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_data_provider_and_separated_cassettes-example-com.yml b/tests/fixtures/with_data_provider_and_separated_cassettes-example-com.yml new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/with_data_provider_and_separated_cassettes-example-com.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0 diff --git a/tests/fixtures/with_data_provider_and_separated_cassettes-example-org.yml b/tests/fixtures/with_data_provider_and_separated_cassettes-example-org.yml new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/with_data_provider_and_separated_cassettes-example-org.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_data_provider_and_separated_cassettes-test-case-with-spaces.yml b/tests/fixtures/with_data_provider_and_separated_cassettes-test-case-with-spaces.yml new file mode 100644 index 0000000..92f524a --- /dev/null +++ b/tests/fixtures/with_data_provider_and_separated_cassettes-test-case-with-spaces.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/0.yml b/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/0.yml new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/0.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0 diff --git a/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/1.yml b/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/1.yml new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/with_data_provider_and_separated_cassettes_in_directory/1.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class.yml b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class.yml new file mode 100644 index 0000000..08e6b4e --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\" without data provider" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/0.yml b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/0.yml new file mode 100644 index 0000000..bba7490 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/0.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\" with numeric urls" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/1.yml b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/1.yml new file mode 100644 index 0000000..f6100b5 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/1.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\" with numeric urls" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-com.yml b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-com.yml new file mode 100644 index 0000000..53b0794 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-com.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\" with named urls" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-org.yml b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-org.yml new file mode 100644 index 0000000..e1b70e5 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_separated_folders/on_class/example-org.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\" with named urls" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-0.yml b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-0.yml new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-0.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-1.yml b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-1.yml new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-1.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-com.yml b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-com.yml new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-com.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-org.yml b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-org.yml new file mode 100644 index 0000000..748aa65 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class-example-org.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.org' + headers: + Host: example.org + response: + status: + code: 200 + message: '' + headers: + age: '331432' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:17:02 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:17:02 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7F83)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.org\"" + index: 0 diff --git a/tests/fixtures/with_separate_cassettes_in_single_folder/on_class.yml b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class.yml new file mode 100644 index 0000000..9447be7 --- /dev/null +++ b/tests/fixtures/with_separate_cassettes_in_single_folder/on_class.yml @@ -0,0 +1,24 @@ +- + request: + method: GET + url: 'https://example.com' + headers: + Host: example.com + response: + status: + code: 200 + message: '' + headers: + age: '455285' + cache-control: max-age=604800 + content-type: 'text/html; charset=UTF-8' + date: 'Sun, 12 Mar 2023 10:20:46 GMT' + etag: '"3147526947+ident"' + expires: 'Sun, 19 Mar 2023 10:20:46 GMT' + last-modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + server: 'ECS (dcb/7EA3)' + vary: Accept-Encoding + x-cache: HIT + content-length: '1256' + body: "Example body for \"https://example.com\"" + index: 0