Skip to content

test: cover the manual phone entry rules - #8285

Merged
vitormattos merged 1 commit into
LibreSign:mainfrom
maia-andre:test/8053-manual-phone-plugin
Sep 7, 2026
Merged

test: cover the manual phone entry rules#8285
vitormattos merged 1 commit into
LibreSign:mainfrom
maia-andre:test/8053-manual-phone-plugin

Conversation

@maia-andre

Copy link
Copy Markdown
Contributor

Related to: #8053

📝 Summary

Infection on lib/Collaboration/Collaborators/ManualPhonePlugin.php reported 18 mutants, 5 escaped and a Covered MSI of 72%. Running it with --with-uncovered shows 22 mutants and 81% mutation code coverage: 4 mutants on lines 43 and 52 were never reached, because no test executed the early return for a context without a raw search, or the one for a number the phone number util rejects.

The dataset written for the rejected number did not reach it. It passed the normalized value as the search term, so the plugin returned on the empty search before ever calling convertToStandardFormat().

This PR changes tests only.

What the tests now protect:

  • the return value of search(), which was never asserted;
  • the exact and the wide result sets, kept apart instead of merged before counting;
  • the whole payload of the offered entry — label, shareWithDisplayNameUnique, method and both values — instead of the share type alone;
  • the two early returns that had no test at all;
  • the trimming of the search and of the raw search, through a scenario with surrounding whitespace on both;
  • that neither the configuration nor the phone number util is touched when there is no number to offer.
before after
Generated mutants 18 22
Killed 13 22
Escaped 5 0
Not covered 4 0
Covered Code MSI 72% 100%

The single test method became three: the valid number, with a data provider for the national number with a default region, the E164 number without one and the whitespace case; the searches that must not be validated at all, with a data provider for the non-phone method, the empty search, the whitespace-only search and the context without a raw search; and the number rejected by the phone number util.

🧪 How to test

composer test:unit -- --filter ManualPhonePluginTest

Expected result:

OK (8 tests, 51 assertions)

Infection, scoped to this source file:

composer mutation:test -- \
  lib/Collaboration/Collaborators/ManualPhonePlugin.php \
  --show-mutations \
  --with-uncovered \
  --threads=1

Expected result:

22 mutations were generated:
      22 mutants were killed by Test Framework

Metrics:
         Mutation Score Indicator (MSI): 100%
         Mutation Code Coverage: 100%
         Covered Code MSI: 100%

One thread is needed here for the same reason described in #8230: with more threads the run reports errors instead of real results.

⚙️ API / Back‑end changes

  • Tests only. No production code, no API and no OpenAPI change.
  • Unit tests added — the whole PR is the test improvement.

✅ Checklist

  • I have read and followed the contribution guide.
  • php-cs-fixer and php -l pass on the changed file.

🤖 AI (if applicable)

  • The content of this PR was partially or fully generated using AI

Infection on ManualPhonePlugin reported 18 mutants with 5 escaped and a
Covered MSI of 72%. Four more mutants were never reached, because no test
executed the early return for a context without a raw search or the one
for a number the phone number util rejects.

The dataset written for the rejected number did not reach it: it passed
the normalized value as the search term, so the plugin returned on the
empty search before ever calling convertToStandardFormat().

The tests now assert the return value of search(), keep the exact and the
wide result sets apart, check the whole payload of the offered entry, and
state that neither the configuration nor the phone number util is touched
when there is no number to offer. Trimming is covered by a scenario with
surrounding whitespace on both the search and the raw search.

Ref LibreSign#8053

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: André Maia <andrefnkmm@gmail.com>
@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in Roadmap Sep 7, 2026
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable35

@vitormattos
vitormattos merged commit 8753b27 into LibreSign:main Sep 7, 2026
68 checks passed
@github-project-automation github-project-automation Bot moved this from 1. to do to 4. to release in Roadmap Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

2 participants