Skip to content

refactor: consolidate pdf fixtures#6197

Merged
vitormattos merged 13 commits intomainfrom
refactor/consolidate-pdf-fixtures
Dec 15, 2025
Merged

refactor: consolidate pdf fixtures#6197
vitormattos merged 13 commits intomainfrom
refactor/consolidate-pdf-fixtures

Conversation

@vitormattos
Copy link
Copy Markdown
Member

No description provided.

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]>
@vitormattos vitormattos added this to the Next Major (33) milestone Dec 15, 2025
@vitormattos vitormattos self-assigned this Dec 15, 2025
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in Roadmap Dec 15, 2025
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]>
@vitormattos
Copy link
Copy Markdown
Member Author

/backport to stable31

@vitormattos
Copy link
Copy Markdown
Member Author

vitormattos commented Dec 15, 2025

/backport to stable32

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]>
@vitormattos vitormattos merged commit 2d3f820 into main Dec 15, 2025
28 checks passed
@vitormattos vitormattos deleted the refactor/consolidate-pdf-fixtures branch December 15, 2025 19:10
@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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant