Koha-clms/t/db_dependent/Koha/Edifact
Martin Renvoize 14064e9459
Bug 40391: Add unit tests for GIR:LSL support in EDI
This adds unit tests for adding support for the new LSL field:

- GIR segment extraction tests in t/Edifact.t for
  sub_location_code field mapping
- Validation function tests in t/db_dependent/Koha/EDI.t
  for location/collection code validation
- Copy function tests in t/db_dependent/Koha/EDI.t for
  location/collection code assignment
- gir_segments generation tests in t/db_dependent/Koha/Edifact/Order.t
  for preference handling

Tests cover:
- LSL field extraction from GIR segments alongside existing LSQ fields
- Independent LSQ/LSL preference mapping (location/ccode/empty combinations)
- Validation of location and collection codes against authorised values
- Error handling and message formatting
- Backwards compatibility with existing LSQ-only configurations
- Edge cases including missing data and invalid preference values
- LSL maps to location, LSQ maps to ccode
- LSL maps to ccode, LSQ maps to location (swapped configuration)
- Only LSL field present (LSQ empty)
- Only LSQ field present (LSL empty)
- Both LSL and LSQ map to location (edge case)
- Both fields disabled

Test plan:
1. Apply this patch
2. Run: prove t/Edifact.t
   - Should pass with 8 new LSL-related tests included
3. Run: prove t/db_dependent/Koha/EDI.t
   - Should pass with 16 new validation function tests
4. Run: prove t/db_dependent/Koha/Edifact/Order.t
   - Should pass with 14 new gir_segments LSL/LSQ tests
5. Verify all existing tests still pass - no regression

Sponsored-by: Westminster City Council <https://www.westminster.gov.uk/>
Sponsored-by: Royal Borough of Kensington and Chelsea <https://www.rbkc.gov.uk/>
Sponsored-by: OpenFifth <https://openfifth.co.uk/>
Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
2026-01-12 10:53:29 -07:00
..
File.t Bug 40163: (follow-up) Fix wrong GNU links and update test 2025-09-24 09:25:04 -06:00
Order.t Bug 40391: Add unit tests for GIR:LSL support in EDI 2026-01-12 10:53:29 -07:00
Transport.t Bug 38489: Update EDI tests to use new file transport system 2025-10-14 14:51:49 -06:00