feat: Add support for separate cassettes per DataProvider cases - #10
Conversation
|
Thank you for the contribution @cb-vova! It's a bit of a busy period for me, but I will try to review this as soon as possible. In meanwhile, can you maybe split this into a few smaller PRs so it'll be easier to review? |
sure. the same thing.. |
|
Thank you again @cb-vova! I left some minor comments, but in general it looks good. |
c6c9fd7 to
4d55c5f
Compare
|
Thank you, @angelov, for the review. |
|
Looks good! Thank you and sorry for the delay. 🍻 |
This PR introduces comprehensive support for creating separate VCR cassettes for each PHPUnit DataProvider case, providing better isolation and organization of HTTP recordings in data-driven tests.
🚀 New Features
Enhanced UseCassette Attribute
separateCassettePerCase: When set totrue, creates individual cassette files for each data provider casegroupCaseFilesInDirectory: When set totrue, organizes separate cassette files in subdirectoriesFlexible Cassette Naming Strategies
cassette-0.yml,cassette-1.ymlcassette-example-com.yml,cassette-example-org.ymlcassette/0.yml,cassette/example-com.ymlClass and Method Level Support
UseCassettedeclared on test classesUseCassettedeclared on individual test methods🔧 Implementation Details
Core Changes
TestCaseParametersandTestMethodInfofor better data handlingData Provider Name Normalization
📚 Documentation
🧪 Test Coverage
AttributeDeclaredOnClassWithSeparateCassettesInSeparateFoldersTestAttributeDeclaredOnClassWithSeparateCassettesInSingleFolderTestWithoutVcrTestAttributeDeclaredOnMethodsTestwith new scenarios🔄 Backward Compatibility
💡 Usage Examples
Basic Separate Cassettes
Organized in Directories
#[UseCassette( name: "api_test.yml", separateCassettePerCase: true, groupCaseFilesInDirectory: true )] #[DataProvider("namedUrls")] public function testApiCalls(string $url): void { // Creates: api_test/example-com.yml, api_test/example-org.yml }This enhancement significantly improves the developer experience when working with data-driven tests that make HTTP requests, providing better isolation, easier debugging, and more organized test fixtures.