Skip to content

test: add edge case tests for HAR file parsing#155

Merged
deviantintegral merged 3 commits intomainfrom
claude/add-har-edge-case-tests-7nlUr
Dec 16, 2025
Merged

test: add edge case tests for HAR file parsing#155
deviantintegral merged 3 commits intomainfrom
claude/add-har-edge-case-tests-7nlUr

Conversation

@deviantintegral
Copy link
Owner

Add test coverage for previously untested edge cases including:

  • Invalid JSON in HAR files
  • Incomplete/truncated JSON data
  • Missing required fields (missing "log" key)
  • Invalid structure (wrong types for fields)
  • Malformed entry data
  • Null values where objects are expected
  • Empty but valid HAR files
  • Minimal valid HAR structures
  • Corrupted binary data
  • Very large HAR files (100+ entries)
  • Whitespace-only files

All malformed test fixtures are isolated in tests/fixtures/edge-cases/ to avoid interfering with existing fixture-based tests.

These tests verify both error handling (proper exceptions thrown) and successful parsing of minimal/empty valid HAR files.

@deviantintegral deviantintegral force-pushed the claude/add-har-edge-case-tests-7nlUr branch from b93fa09 to 77a9167 Compare December 16, 2025 21:08
Add test coverage for previously untested edge cases including:
- Invalid JSON in HAR files
- Incomplete/truncated JSON data
- Missing required fields (missing "log" key)
- Invalid structure (wrong types for fields)
- Malformed entry data
- Null values where objects are expected
- Empty but valid HAR files
- Minimal valid HAR structures
- Corrupted binary data
- Very large HAR files (100+ entries)
- Whitespace-only files

All malformed test fixtures are isolated in tests/fixtures/edge-cases/
to avoid interfering with existing fixture-based tests.

These tests verify both error handling (proper exceptions thrown) and
successful parsing of minimal/empty valid HAR files.
Replace generic \Exception assertions with specific exception types:
- JMS\Serializer\Exception\RuntimeException for JSON parsing errors
- TypeError for null values in typed properties
- \Error for uninitialized property access

This makes tests more precise and helps catch regressions where
the wrong type of exception might be thrown.
Remove testMissingLogKeyResultsInUninitializedProperty() from EdgeCaseTest
as commit 9d938fb properly fixed this issue by adding PostDeserialize
validation in the Har class. The missing log key validation is now
properly covered by MissingLogKeyTest.php which tests the correct
behavior (exception thrown during deserialization).

The old test was checking for the bug behavior (uninitialized property
error when accessing getLog()), which no longer occurs.
@deviantintegral deviantintegral force-pushed the claude/add-har-edge-case-tests-7nlUr branch from b84dca4 to b601ff8 Compare December 16, 2025 21:32
@deviantintegral deviantintegral marked this pull request as ready for review December 16, 2025 21:46
@deviantintegral deviantintegral merged commit c9680a7 into main Dec 16, 2025
8 checks passed
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