Skip to content

test: pin curl behavior for EncryptedFile::upload and SupportingDocumentTemplate::download - #119

Open
Fivell wants to merge 2 commits into
masterfrom
test/upload-download-coverage
Open

test: pin curl behavior for EncryptedFile::upload and SupportingDocumentTemplate::download#119
Fivell wants to merge 2 commits into
masterfrom
test/upload-download-coverage

Conversation

@Fivell

@Fivell Fivell commented Aug 3, 2026

Copy link
Copy Markdown
Member

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.

Fivell added 2 commits August 3, 2026 12:00
…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.
@Fivell Fivell self-assigned this Aug 3, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

@Fivell Fivell changed the title code cleanup test: pin curl behavior for EncryptedFile::upload and SupportingDocumentTemplate::download Aug 3, 2026
@Fivell
Fivell requested a review from Copilot August 6, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_headers matching enabled, omitting the Host header 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants