Skip to content

test: kill 74 escaped Infection mutants across PDF builder, PNG embedder, font metrics, and compiler#17

Merged
vitormattos merged 1 commit into
mainfrom
copilot/resolve-infection-issues
May 29, 2026
Merged

test: kill 74 escaped Infection mutants across PDF builder, PNG embedder, font metrics, and compiler#17
vitormattos merged 1 commit into
mainfrom
copilot/resolve-infection-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 29, 2026

The last Infection run on PR #16 reported 74 escaped mutants — mutations that were not caught by any test, indicating untested behavioral branches.

Changes

StandardFontMetrics (mutants 65–68)

  • Add tests asserting measureString returns 0.0 for empty text with positive font size (kills LogicalOr mutant), for non-empty text with fontSize = 0.0 exactly (kills LessThanOrEqualTo), and comparing F3 (Times-Roman) vs. F1/F2 measurements to pin the in_array(['F3','F4']) branch (kills ArrayItemRemoval)

FilesystemPdfImageEmbedder (mutants 1–55)

  • Add JPEG tests with 1-channel (grayscale) and 4-channel (CMYK) payloads to cover all match($channels) arms
  • Add multi-pixel, multi-row RGBA PNG fixtures to pin $colorRow .= / $alphaRow .= accumulation semantics and $colorScanlines .= / $alphaScanlines .= (kills Assignment mutants)
  • Add PNG fixtures for colorType 0 (grayscale) and 4 (grayscale+alpha) to cover those describePngColorType arms and the soft-mask path for grayscale-alpha
  • Add test with multi-IDAT-chunk PNG to verify IDAT concatenation (kills Assignment mutant 39 and Break_ mutant 40)
  • Add tests for unsupported colorType (kills MatchArmRemoval/Throw_ mutants 32–33), invalid PNG signature (kills MethodCallRemoval mutant 34), and compression/filter header validation (kills LogicalOr mutant 45)

SinglePagePdfExporter (mutants 56–64)

  • Add test asserting integer dictionary values are serialized as numbers via formatNumber (kills CastFloat mutant 56)
  • Add test with nested non-name array values to exercise array_map serialization (kills UnwrapArrayMap mutant 57)
  • Add test verifying xref section includes all object references (kills loop mutants 59–62)
  • Add tests where a string value like "prefix 1 0 R" or "1 0 R suffix" must NOT be treated as a raw PDF reference, to pin both anchors in /^\d+ 0 R$/ (kills PregMatchRemoveCaret 63 and PregMatchRemoveDollar 64)

TemplateDocumentBuilder (mutants 69–73)

  • Add decoration tests: strokeColor set but strokeWidth = 0.0 must not produce a stroke (kills GreaterThan mutant 71); strokeColor = null with positive strokeWidth must not produce a stroke (kills LogicalAnd mutants 69–70)
  • Add decoration with borderRadius larger than half the smallest dimension to assert the radius is clamped to min(w/2, h/2) — catches both DivisionMultiplication mutations (mutants 72–73)

XObjectTemplateCompiler (mutant 74)

  • Add test providing an explicit HtmlContextInterpolator instance and verifying it is wired into the compiler, catching the Coalesce flip mutation
Original prompt

A última execução ainda retornou muitos problemas no Infection.
https://github.com/LibreSign/xobject-template/actions/runs/26637292748/job/78500742231?pr=16
Resolva todos, quero o infection todo verde.

Para resolver os problemas do Infection e garantir que todos os testes estejam passando, você pode seguir os seguintes passos:

  1. Verifique os Resultados do Infection: Acesse o link que você forneceu e veja quais testes estão falhando. O Infection fornece um relatório detalhado sobre quais partes do código não estão sendo cobertas pelos testes.

  2. Revise os Testes: Abra o arquivo /home/username/projects/xobject-template/tests/Unit/Layout/TextBoxLayouterTest.php e revise os testes existentes. Veja se há alguma lógica que não está sendo testada ou se os testes não estão cobrindo todos os cenários.

  3. Adicione Testes Faltantes: Se você identificar que há cenários que não estão sendo testados, adicione novos testes para cobrir essas situações. Certifique-se de que cada parte do código que pode ser afetada por mudanças esteja sendo testada.

  4. Execute os Testes Localmente: Antes de rodar o Infection novamente, execute todos os testes localmente para garantir que eles estão passando. Você pode usar o comando:

    ./vendor/bin/phpunit
  5. Rode o Infection: Após garantir que todos os testes estão passando, execute o Infection novamente para verificar a cobertura. Use o comando:

    ./vendor/bin/infection
  6. Analise os Resultados: Veja se a cobertura melhorou e se todos os problemas foram resolvidos. Se ainda houver falhas, repita o processo de revisão e adição de testes.

  7. Commit e Push: Quando todos os testes estiverem passando e a cobertura estiver verde, faça um commit das suas alterações e envie para o repositório.

Se precisar de ajuda específica com algum teste ou parte do código, sinta-se à vontade para compartilhar!

Created from VS Code.

Copilot AI changed the title [WIP] Fix all issues reported by Infection test: kill 74 escaped Infection mutants across PDF builder, PNG embedder, font metrics, and compiler May 29, 2026
Copilot AI requested a review from vitormattos May 29, 2026 13:05
@vitormattos vitormattos force-pushed the copilot/resolve-infection-issues branch from f59690f to 3950573 Compare May 29, 2026 13:14
@vitormattos vitormattos marked this pull request as ready for review May 29, 2026 13:20
@vitormattos vitormattos merged commit 179b9f7 into main May 29, 2026
22 of 24 checks passed
@vitormattos vitormattos deleted the copilot/resolve-infection-issues branch June 1, 2026 20:59
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