Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Standardize PHPUnit test names to match source classes

Aperta
#9,146 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
testing

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

enhancement good first issue php

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.php
  • tests/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/ or tests/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.php is renamed to CrlMapperTest.php.
  • FolderServiceDbTest.php is renamed to FolderServiceTest.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 CrlMapperTest
  • composer test:integration -- --filter FolderServiceTest
  • composer test:integration -- --filter SignFileJobTest
  • composer test:integration -- --filter SignSingleFileJobTest
  • composer lint
  • composer 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

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di LibreSign/libresign

Tutte le issue di LibreSign/libresign

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.