Bug 41649: Unit tests for magnetic media

Add unit tests for SIP magnetic media support.

Test plan
1) Run t/db_dependent/SIP/Transaction.t in ktd and confirm it passes

Sponsored-by: OpenFifth <https://openfifth.co.uk/>
Signed-off-by: Marcus Michel <marcus.michel@rbkc.gov.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-01-16 08:13:35 +00:00 committed by Pedro Amorim
parent df7e600587
commit cd728e5bb2
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 52 additions and 1 deletions

View File

@ -5,7 +5,7 @@
use Modern::Perl;
use Test::NoWarnings;
use Test::More tests => 22;
use Test::More tests => 23;
use Test::Warn;
use DateTime;
@ -1676,4 +1676,55 @@ subtest 'Checkin message' => sub {
is( $circ->{screen_msg}, '', "Checked out item was checked out to the next patron" );
};
subtest 'magnetic_media flag from item type' => sub {
plan tests => 4;
# Create an item type with magnetic = 1
my $itemtype_magnetic = $builder->build_object(
{
class => 'Koha::ItemTypes',
value => {
itemtype => 'MAGNETIC',
description => 'Magnetic Test Item Type',
sip_magnetic => 1,
}
}
);
# Create an item type with magnetic = 0
my $itemtype_non_magnetic = $builder->build_object(
{
class => 'Koha::ItemTypes',
value => {
itemtype => 'NONMAG',
description => 'Non-Magnetic Test Item Type',
sip_magnetic => 0,
}
}
);
# Create items with these types
my $item_magnetic = $builder->build_sample_item(
{
itype => $itemtype_magnetic->itemtype,
}
);
my $item_non_magnetic = $builder->build_sample_item(
{
itype => $itemtype_non_magnetic->itemtype,
}
);
# Test magnetic item
my $sip_item_magnetic = C4::SIP::ILS::Item->new( $item_magnetic->barcode );
ok( defined $sip_item_magnetic, 'SIP Item object created for magnetic item' );
is( $sip_item_magnetic->magnetic_media, 1, 'magnetic_media is 1 for magnetic item type' );
# Test non-magnetic item
my $sip_item_non_magnetic = C4::SIP::ILS::Item->new( $item_non_magnetic->barcode );
ok( defined $sip_item_non_magnetic, 'SIP Item object created for non-magnetic item' );
is( $sip_item_non_magnetic->magnetic_media, 0, 'magnetic_media is 0 for non-magnetic item type' );
};
$schema->storage->txn_rollback;