Skip to content

test: assert full exception messages, codes and previous-chains#50

Merged
turegjorup merged 2 commits into
developfrom
test/mutation-exception-assertions
Jun 11, 2026
Merged

test: assert full exception messages, codes and previous-chains#50
turegjorup merged 2 commits into
developfrom
test/mutation-exception-assertions

Conversation

@turegjorup

Copy link
Copy Markdown
Collaborator

Summary

First of three scoped follow-ups to #49 killing surviving mutants to push the mutation score above 90%. Targets the largest cluster: exception-contract assertions (33 of 57 escaped mutants).

Features Added

  • Claims/validation failures (validateIdToken) assert the complete message including the dynamic part — audience list, issuer, nonce — so the concatenation can't be dropped or reordered undetected
  • Wrap-boundary tests (ValidationException, CodeException, HttpException, JsonException, CacheException, IdentityProviderException) assert code 0 and the chained $previous cause
  • Constructor URL failures assert the offending URL in the message (BadUrlException, IllegalSchemeException); DecodeException asserts the input; HttpException asserts the resource URL
  • New testGetIdTokenRejectsInvalidJsonResponse: invalid JSON from the token endpoint wraps \JsonException into CodeException (kills a Catch_ mutant on the union catch)

Files Changed

  • tests/Security/OpenIdConfigurationProviderTest.php - assertion strengthening + one new test
  • CHANGELOG.md - Unreleased bullet

Test Plan

  • vendor/bin/phpunit — 98 tests, 168 assertions, green
  • vendor/bin/infection — 24 escaped mutants remaining, down from 57 (Covered Code MSI 71% → 87%)
  • PHPStan max level + php-cs-fixer — clean

🤖 Generated with Claude Code

Mutation testing showed the exception contract was only half-verified:
expectExceptionMessage() matched static prefixes, so every dynamic
message part (offending URL, audience list, issuer, nonce, input)
could be dropped or reordered undetected, and the 0 code passed at
each wrap boundary was never asserted. Wrap-boundary tests now check
the full message, code 0 and the chained previous cause, and a new
test covers invalid JSON from the token endpoint. Kills 33 of 57
escaped mutants (71% -> 87% covered MSI).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ption-assertions

# Conflicts:
#	CHANGELOG.md
@turegjorup turegjorup merged commit d5ebdd0 into develop Jun 11, 2026
15 checks passed
@turegjorup turegjorup deleted the test/mutation-exception-assertions branch June 11, 2026 09:12
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7d72ac7) to head (dc256f3).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop       #50   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity        71        71           
===========================================
  Files              1         1           
  Lines            185       185           
===========================================
  Hits             185       185           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant