From bd0afec29758bf5f5c7203285bf121edda657c6c Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Thu, 31 Aug 2023 19:11:04 +0000 Subject: [PATCH] Bug 21272: Unit test Signed-off-by: David Nind Signed-off-by: PhilipOrr --- t/db_dependent/ImportBatch.t | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t index 2e51162bf3..81e523712a 100755 --- a/t/db_dependent/ImportBatch.t +++ b/t/db_dependent/ImportBatch.t @@ -232,7 +232,7 @@ my $import_batch = C4::ImportBatch::GetImportBatch($id_import_batch3); is( $import_batch, undef, "Batch 3 has been deleted" ); subtest "_batchCommitItems" => sub { - plan tests => 3; + plan tests => 6; my $exist_item = $builder->build_sample_item; my $import_item = $builder->build_object( @@ -270,6 +270,34 @@ subtest "_batchCommitItems" => sub { $import_item->import_error, 'duplicate item barcode', 'Error correctly set when import item has duplicate barcode and action always_add' ); + + $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => { + marcxml => q{ + + + + 00000 a + + WBRC + WBRC + GEN + BCDETEST + BK + + + + }, + }}); + + ( $num_items_added, $num_items_replaced, $num_items_errored ) = + C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, 32, 'always_add',64 ); + is( $num_items_errored, 1, "Item with wrong branchcode fails when action always_add" ); + $import_item->discard_changes(); + is( $import_item->status, 'error', "Import item marked as error when wrong branchcode detected and action always_add"); + is( $import_item->import_error, 'Branch code WBRC missing', 'Error correctly set when import item has a wrong branchcode detected and action always_add' ); }; subtest "RecordsFromMarcPlugin" => sub { -- 2.39.5