Skip to content

[stable31] refactor: consolidate pdf fixtures#6199

Merged
vitormattos merged 13 commits intostable31from
backport/6197/stable31
Dec 15, 2025
Merged

[stable31] refactor: consolidate pdf fixtures#6199
vitormattos merged 13 commits intostable31from
backport/6197/stable31

Conversation

@backportbot-libresign
Copy link
Copy Markdown

Backport of PR #6197

Consolidate PDF fixture generation into a single static class:
- Migrate all methods from PdfFixtureTrait to PdfGenerator
- Convert trait methods to public static methods
- Maintain all existing functionality
- Includes 20+ methods for ISO 32000-1 edge case testing

This improves code organization and eliminates trait usage.

Signed-off-by: Vitor Mattos <[email protected]>
Delete trait after migrating all methods to PdfGenerator.
The trait pattern was unnecessary for stateless utility methods.

Signed-off-by: Vitor Mattos <[email protected]>
Replace PdfFixtureTrait usage with PdfGenerator static methods:
- Remove 'use PdfFixtureTrait' statements
- Add 'use OCA\Libresign\Tests\Fixtures\PdfGenerator' imports
- Change trait method calls to static PdfGenerator:: calls
- Fix incorrect PdfGenerator::createMock() to $this->createMock()

Affected test files:
- DocMdpHandlerTest
- FileServiceTest (3 createMock fixes)
- SignFileServiceTest (20+ createMock fixes)
- PdfParseServiceTest
- PdfSignatureDetectionServiceTest
- RequestSignatureServiceTest
- ValidateHelperTest
- AEnvironmentPageAwareControllerTest

Signed-off-by: Vitor Mattos <[email protected]>
Replace PdfFixtureTrait with PdfGenerator in API tests:
- FileControllerTest
- FileElementControllerTest
- IdDocsControllerTest
- NotifyControllerTest
- RequestSignatureControllerTest
- SignFileControllerTest

Signed-off-by: Vitor Mattos <[email protected]>
Clean up test code by:
- Removing verbose docblocks and obvious comments
- Simplifying assertion messages
- Deleting 2 redundant tests (extraction and validation)
- Reducing file size from 180 to 46 lines (74% reduction)

All 21 tests still pass with maintained coverage.

Signed-off-by: Vitor Mattos <[email protected]>
Create catalog system for managing real-world signed PDFs:
- PdfFixtureCatalog class with YAML-based metadata
- Filter by DocMDP level, TSA, signature tool, count
- Provides expected validation results for tests
- Includes PdfFixture wrapper for easy access
- Store real PDFs in tests/php/fixtures/pdfs/ directory

Signed-off-by: Vitor Mattos <[email protected]>
Delete PDFs from root fixtures directory.
Files now organized in tests/php/fixtures/pdfs/ with catalog.

Signed-off-by: Vitor Mattos <[email protected]>
Update composer.json and Pkcs12Handler changes from refactoring.

Signed-off-by: Vitor Mattos <[email protected]>
Add SPDX license and copyright headers to comply with REUSE specification.

Signed-off-by: Vitor Mattos <[email protected]>
Signed-off-by: Vitor Mattos <[email protected]>
Signed-off-by: Vitor Mattos <[email protected]>
Update path from tests/php/fixtures/small_valid.pdf to
tests/php/fixtures/pdfs/small_valid.pdf after file reorganization.

Fixes /apps/libresign/develop/pdf route.

Signed-off-by: Vitor Mattos <[email protected]>
Update paths to reflect new organization in pdfs/ subdirectory:
- tests/php/fixtures/real_jsignpdf_level1.pdf -> tests/php/fixtures/pdfs/real_jsignpdf_level1.pdf
- tests/php/fixtures/small_valid-signed.pdf -> tests/php/fixtures/pdfs/small_valid-signed.pdf
- tests/php/fixtures/small_valid.pdf -> tests/php/fixtures/pdfs/small_valid.pdf

Signed-off-by: Vitor Mattos <[email protected]>
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in Roadmap Dec 15, 2025
@backportbot-libresign backportbot-libresign Bot added this to the Next Patch (31) milestone Dec 15, 2025
@vitormattos vitormattos merged commit 67ae46a into stable31 Dec 15, 2025
61 checks passed
@vitormattos vitormattos deleted the backport/6197/stable31 branch December 15, 2025 19:26
@github-project-automation github-project-automation Bot moved this from 0. Needs triage to 4. to release in Roadmap Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant