Standardize PHPUnit test names to match source classes
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 72/100
Direzione di ricerca
Read the existing tests at tests/php/Integration/Db/CrlMapperDbTest.php, tests/php/Integration/Service/FolderServiceDbTest.php, and tests/php/Integration/AppInfo/BackgroundJobsRegistrationTest.php, plus the production class paths named in the issue. Then update the test names and split the registration checks into job specific integration tests using IAppManager::getAppInfoByPath(). Run the listed integration filters and style checks; done means the renamed tests are discovered and both jobs are checked against automatic registration metadata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Goal
Make PHPUnit integration tests easy to find by matching test paths and class names to the production classes they cover.
When a test protects the behavior of a specific class, use the same relative directory and class name, with the Test suffix.
Why this matters
Maintainers should be able to find the tests for a source class by following the directory structure.
Creating separate PHPUnit classes for individual behaviors makes it harder to discover related tests. Searching the repository is not always reliable when tests use mocks, dependency injection, or indirect calls.
Use test method names and data providers to describe different behaviors of the same class.
Required changes
1. CrlMapper
Rename:
tests/php/Integration/Db/CrlMapperDbTest.php
to:
tests/php/Integration/Db/CrlMapperTest.php
The matching production file is lib/Db/CrlMapper.php.
Keep the existing assertions and test behavior unchanged.
2. FolderService
Rename:
tests/php/Integration/Service/FolderServiceDbTest.php
to:
tests/php/Integration/Service/FolderServiceTest.php
The matching production file is lib/Service/FolderService.php.
Keep the existing assertions and test behavior unchanged.
3. Signing background jobs
The current test:
tests/php/Integration/AppInfo/BackgroundJobsRegistrationTest.php
checks two different production classes.
Replace it with two focused integration tests:
SignFileJob
- Production:
lib/BackgroundJob/SignFileJob.php - Test:
tests/php/Integration/BackgroundJob/SignFileJobTest.php - Test class:
SignFileJobTest
SignSingleFileJob
- Production:
lib/BackgroundJob/SignSingleFileJob.php - Test:
tests/php/Integration/BackgroundJob/SignSingleFileJobTest.php - Test class:
SignSingleFileJobTest
Each test must verify that its corresponding job is not declared as an automatically registered background job.
Use the Nextcloud IAppManager::getAppInfoByPath() API to inspect the parsed appinfo/info.xml metadata.
This matters because both signing jobs require arguments provided when a signing request is queued. They must not be registered automatically without those arguments.
Do not replace this check with only IJobList::has($job, null). That API checks the current queue state and does not prove the app metadata is correct.
Do not add registration-check methods to the production job classes just for testing.
After moving both assertions, remove the old BackgroundJobsRegistrationTest.php.
Existing coverage
Keep the existing tests that verify programmatic job enqueuing, including:
tests/php/Unit/Service/AsyncSigningServiceTest.phptests/php/Unit/Service/SignFileServiceTest.php
Keep tests/php/Unit/BackgroundJob/SignSingleFileJobTest.php, which verifies delegation to its coordinator.
The new integration tests must preserve the existing regression protection without duplicating unrelated signing tests.
Naming convention
For a test with one primary production PHP class:
- Use the same relative directory under
tests/php/Unit/ortests/php/Integration/. - Name the file
<SourceClass>Test.php. - Name the PHPUnit class
<SourceClass>Test. - Keep different behaviors in clearly named test methods or data providers.
- Allow unit and integration tests to share a short class name because their namespaces are different.
Tests for genuine cross-component contracts or configuration artifacts may use a different name when there is no single responsible production class. The relationship to the tested artifact must remain clear.
Shared test base classes are excluded from this convention.
Documentation
Update the naming guidance in:
LibreSign/libresign/AGENTS.md, using a short operational rule.LibreSign/documentation/developer_manual/getting-started/tests.rst, with examples and the reason for the convention.
Keep the detailed explanation in the Developer Manual.
Acceptance criteria
-
CrlMapperDbTest.phpis renamed toCrlMapperTest.php. -
FolderServiceDbTest.phpis renamed toFolderServiceTest.php. - The background job registration test is replaced by two job-specific integration test classes.
- Each new background job test checks only its corresponding job.
- Both tests fail if their corresponding job is declared in the automatic background job registration metadata.
- Valid programmatic job enqueuing remains covered by existing tests.
- The old generic registration test is removed only after its assertions have been preserved.
- PHPUnit discovers all renamed and new tests.
- The naming rule and justified exceptions are documented.
- Relevant PHP linting and coding-style checks pass.
- No production behavior is changed.
Verification
Run the relevant integration tests using the existing Nextcloud development environment:
composer test:integration -- --filter CrlMapperTestcomposer test:integration -- --filter FolderServiceTestcomposer test:integration -- --filter SignFileJobTestcomposer test:integration -- --filter SignSingleFileJobTestcomposer lintcomposer cs:check
Check the relevant GitHub Actions results and report which commands actually ran.
Related PR
PR #9071 adds SignRequestMapperSearchPaginationTest.php.
That PR should rename the file and class to SignRequestMapperTest, keeping the existing tests and assertions.
The PR author can make this small change independently. This issue documents and applies the convention to existing tests.
Out of scope
- Changing production job registration or execution.
- Changing the signing flow.
- Changing existing job queue behavior.
- Rewriting unrelated tests.
- Introducing a new naming linter.
- Moving tests that depend on Nextcloud into the unit suite.
Good first issue
This task has specific files, known production classes, and focused verification steps.
Interested contributors may comment before starting so maintainers can confirm the issue remains current and clarify questions. This is optional.
Developer testing guide: https://docs.libresign.coop/developer_manual/getting-started/tests.html
- Lingua principale
- PHP
- Stelle
- 835
- Fork
- 167
- Merge medio
- 17h 1m
- PR unite (30g)
- 477
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di LibreSign/libresign
-
frontend good first issue help wanted javascript technical debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
LibreSign/libresign#9007 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
backend enhancement php
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
LibreSign/libresign#8284 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
frontend good first issue help wanted javascript technical debt
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di LibreSign/libresign
Issue simili
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
Source item status is not saved when stock is deducted on shipment (stays "In Stock" at qty 0)ApertaIssue: ready for confirmation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Перевод устарел
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
LinkStackOrg/LinkStack#1014 · 2 commenti ·