test: pin curl behavior for EncryptedFile::upload and SupportingDocumentTemplate::download - #119
Open
Fivell wants to merge 2 commits into
Open
test: pin curl behavior for EncryptedFile::upload and SupportingDocumentTemplate::download#119Fivell wants to merge 2 commits into
Fivell wants to merge 2 commits into
Conversation
…dFile::upload Adds VCR-cassette-backed coverage for the current hand-rolled curl implementation of EncryptedFile::upload(): exact multipart field names, default filename/content-type/content-transfer-encoding per part, and the Api-Key/X-DIDWW-API-Version/Content-Type/Content-Length/Accept request headers it sends. Also covers both the success (201) and error (422) response-handling paths through UploadResult. Sets VCR mode to MODE_NONE for the duration of this test class so a request that fails to match its recorded cassette raises immediately instead of silently falling through to a real sandbox call.
Adds VCR-cassette-backed coverage for the current hand-rolled curl implementation of SupportingDocumentTemplate::download(): confirms no custom request headers are sent, and that the response body is written verbatim to both a file path and an existing resource handle. Sets VCR mode to MODE_NONE for the duration of this test class so a request that fails to match its recorded cassette raises immediately instead of silently falling through to a real sandbox call.
|
There was a problem hiding this comment.
Pull request overview
Adds regression coverage to lock in the current curl/VCR-recorded HTTP behavior for SupportingDocumentTemplate::download() and EncryptedFile::upload() so future refactors can’t inadvertently change wire-level request/response handling.
Changes:
- Add VCR “hard fail” mode (
MODE_NONE) during these test cases to prevent silent cassette re-recording on mismatches. - Add download tests for
SupportingDocumentTemplate(path + resource handle destinations). - Add multipart-body structure and upload success/error tests for
EncryptedFile, plus new cassette recordings.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/SupportingDocumentTemplateTest.php | Adds download regression tests and enforces strict VCR mode for the class. |
| tests/fixtures/supporting_document_templates.yml | Adds a recorded storage download response used by the new download tests. |
| tests/fixtures/encrypted_files.yml | Adds recorded multipart upload requests/responses used by the new upload tests. |
| tests/EncryptedFileTest.php | Adds multipart construction + upload regression tests and enforces strict VCR mode for the class. |
Suppressed comments (1)
tests/fixtures/encrypted_files.yml:213
- Same issue as the previous POST: with
custom_headersmatching enabled, omitting theHostheader makes this cassette entry fail to match the real curl request, causing a hard failure in MODE_NONE.
headers:
Api-Key: PLACEYOURAPIKEYHERE
X-DIDWW-API-Version: '2026-04-16'
Content-Type: 'multipart/form-data; boundary=-------------TESTBOUNDARY0002'
Content-Length: '370'
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+187
to
+195
| request: | ||
| method: POST | ||
| url: 'https://sandbox-api.didww.com/v3/encrypted_files' | ||
| headers: | ||
| Api-Key: PLACEYOURAPIKEYHERE | ||
| X-DIDWW-API-Version: '2026-04-16' | ||
| Content-Type: 'multipart/form-data; boundary=-------------TESTBOUNDARY0001' | ||
| Content-Length: '501' | ||
| Accept: application/json |
Comment on lines
+41
to
+44
| request: | ||
| method: GET | ||
| url: 'https://sandbox-api.didww.com/storage/public/w7f2irbo819la7vd7up7u67pkmkn' | ||
| response: |
Comment on lines
+78
to
+80
| $reflection = new \ReflectionMethod(\Didww\Item\EncryptedFile::class, 'buildDataFiles'); | ||
|
|
||
| return $reflection->invoke(null, $delimiter, $files, $fields); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds regression tests pinning the current curl-based behavior of EncryptedFile::upload() and SupportingDocumentTemplate::download() (neither had HTTP-mocking-level coverage before). Tests only, no production code changes — a safety net ahead of a possible future refactor of these two methods.