test: assurance-audit指摘のC3/D4テスト不備を修正 - #199
Merged
Merged
Conversation
- SecretScrubberTest: json_encode経由のアサートは例外オブジェクトが
protected/privateプロパティのため常に{}になり、伏字化の有無に
かかわらず結果が変わらない見せかけの保証だった。scrubArray()の
戻り値を直接アサートする形に修正し、5文字境界値の伏字化テストを追加。
- UpdateOrCreatePageWithPaksTest: 「DB::transactionが呼ばれたか」の
モック確認と正常系コミットのみで、途中失敗時のロールバックを
検証するテストが無かった欠落を追加。SyncPak/UpdateOrCreatePageは
finalで差し替え不可なため、契約違反値を渡し実コードの本物の失敗
経路でロールバックを検証する形にした。
- 修正前の実装にバグを注入し、両テストが実際にredになることを
確認済み(見せかけの保証ではないことの検証)。
- docs/known-risks.md のC3/B4/D4テスト件数を追加分に合わせて更新。
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.
Summary
2026-08-26 実施の assurance-audit で見つかった、テストが実際には仕様を保証していなかった2件を修正する。
SecretScrubberTest::test_scrub_array_recurses_and_masks_throwableがjson_encode($result)経由でアサートしていたため機能していなかった。PHPの例外オブジェクトは protected/private プロパティのためjson_encodeすると{}になり、walk()のThrowable伏字化処理が効いていようがいまいがテスト結果が変わらない見せかけの保証だった。scrubArray()の戻り値を直接アサートする形に修正。あわせてmb_strlen($value) >= 5の長さ境界(ちょうど5文字)の伏字化を確認する境界値テストを追加。UpdateOrCreatePageWithPaksTestの既存2テストは「DB::transaction()が呼ばれたか」のモック確認と正常系のコミット成功のみで、実際に途中失敗させてロールバックを確認するテストが無かった。SyncPak/UpdateOrCreatePageがfinalのため Mockery 等での差し替えができない制約があり、array<int,PakSlug>という契約に反する値を渡すことで実コード内に本物の失敗($pak->valueの読み取り失敗)を起こし、モックではなく本物のトランザクション・本物の例外経路でロールバックを検証するテストを追加。両テストとも、修正前の実装にバグを注入して実際にredになることを確認済み(見せかけの保証ではないことの検証)。
docs/known-risks.mdのC3/B4/D4のテスト件数も追加分に合わせて更新した。Test plan
php artisan test --testsuite=Feature全81件greenphp artisan test --testsuite=Unitgreencomposer run pint:checkpasscomposer run stanno errors