Bug 32456: Unit tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit ac6b7f9b58)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2022-12-16 15:46:48 +00:00 committed by Jacob O'Mara
parent a7f471c548
commit 811f676da0
1 changed files with 19 additions and 1 deletions

View File

@ -766,7 +766,7 @@ subtest 'Split subfields in Item2Marc (Bug 21774)' => sub {
};
subtest 'ModItemFromMarc' => sub {
plan tests => 7;
plan tests => 8;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
@ -840,6 +840,24 @@ subtest 'ModItemFromMarc' => sub {
is( $item->get_from_storage->onloan, '2022-03-26', 'onloan has been updated when passed in' );
};
subtest 'dateaccessioned' => sub {
plan tests => 3;
my $item = $builder->build_sample_item;
$item->set({ dateaccessioned => '2022-03-19' })->store->discard_changes;
is( $item->dateaccessioned, '2022-03-19', 'init values set are expected' );
my $marc = C4::Items::Item2Marc( $item->get_from_storage->unblessed, $item->biblionumber );
my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.dateaccessioned' );
$marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
is( $item->get_from_storage->dateaccessioned, '2022-03-19', 'dateaccessioned has not been updated if not passed' );
$marc = C4::Items::Item2Marc( { %{$item->unblessed}, dateaccessioned => '2022-03-26' }, $item->biblionumber );
ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
is( $item->get_from_storage->dateaccessioned, '2022-03-26', 'dateaccessioned has been updated when passed in' );
};
subtest 'permanent_location' => sub {
plan tests => 10;