Bug 41719

Summary: Add rendering test coverage for Labels and Patroncards
Product: Koha Reporter: Chris Nighswonger <chris.nighswonger>
Component: Test SuiteAssignee: Chris Cormack <chris>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 41719: Add rendering test coverage for Labels and Patroncards

Description Chris Nighswonger 2026-01-27 03:06:26 UTC
The label and patron card rendering code paths in C4::Labels::Label and C4::Patroncards::Patroncard lack test coverage for their core drawing methods.

This patch adds:
 - t/db_dependent/Labels/t_Label.t - Extends existing tests with subtests for:
   - draw_label_text() - text positioning and formatting
   - draw_guide_box() - guide box rendering
   - barcode() - all supported barcode types (CODE39, COOP2OF5, INDUSTRIAL2OF5, EAN13)
   - create_label() - printing type orchestration (BIB, BAR, BIBBAR, BARBIB)
 - t/db_dependent/Patroncards/t_Patroncard.t - New test file covering:
   - draw_guide_box() and draw_guide_grid()
   - draw_text() with patron data substitution
   - draw_barcode() with multiple barcode types
   - draw_image() with generated test image
   - End-to-end PDF output validation

Tests use t::lib::TestBuilder fixtures and transaction rollback for isolation.

AI Disclosure:
  This contribution was developed with AI assistance (Claude Opus 4.5, Anthropic). See commit message for full disclosure per
  https://wiki.koha-community.org/wiki/Coding_Guidelines#.5BDRAFT.5D_AI_and_LLM-assisted_contributions.
Comment 1 Chris Nighswonger 2026-01-27 03:14:40 UTC
Created attachment 192076 [details] [review]
Bug 41719: Add rendering test coverage for Labels and Patroncards

Extends t/db_dependent/Labels/t_Label.t with subtests for:
- draw_label_text() structure validation
- draw_guide_box() PDF stream output
- All supported barcode types (CODE39, CODE39MOD, CODE39MOD10,
  COOP2OF5, INDUSTRIAL2OF5, EAN13)
- create_label() printing type orchestration (BIB/BAR/BIBBAR/BARBIB)

Creates t/db_dependent/Patroncards/t_Patroncard.t with subtests for:
- draw_guide_box(), draw_guide_grid(), draw_text()
- draw_barcode(), draw_image()
- End-to-end PDF output

AI Assistance: Claude Opus 4.5 drafted test code and debugged a
PDF::Reuse issue (GitHub cnighswonger/PDF-Reuse#24, fixed in 0.43).
Human author directed the approach, rejected initial implementation
that merely exercised PDF::Reuse rather than Koha code, reviewed all
changes, and verified tests pass.

Assisted-by: Claude Opus 4.5 (Anthropic)