From 11e8ec81f229be3ac255683c1c5cc120a6876118 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 23 May 2022 12:18:11 +0000 Subject: [PATCH] Bug 30831: Unit test Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- t/db_dependent/ImportBatch.t | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t index 7548c398ab..5471fb1b70 100755 --- a/t/db_dependent/ImportBatch.t +++ b/t/db_dependent/ImportBatch.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 18; +use Test::More tests => 19; use utf8; use File::Basename; use File::Temp qw/tempfile/; @@ -183,6 +183,39 @@ C4::ImportBatch::DeleteBatch( $id_import_batch3 ); my $import_batch = C4::ImportBatch::GetImportBatch( $id_import_batch3 ); is( $import_batch, undef, "Batch 3 has been deleted"); +subtest "BatchCommitItems" => sub { + plan tests => 3; + + my $exist_item = $builder->build_sample_item; + my $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => { + marcxml => q{ + + + + 00000 a + + CPL + CPL + GEN + }.$exist_item->barcode.q{ + BK + + + + }, + }}); + + my ( $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 duplicate barcode fails when action always_add" ); + $import_item->discard_changes(); + is( $import_item->status, 'error', "Import item marked as error when duplicate barcode and action always_add"); + is( $import_item->import_error, 'duplicate item barcode', 'Error correctly set when import item has duplciate barcode and action always_add' ); +}; + subtest "RecordsFromMarcPlugin" => sub { plan tests => 5; -- 2.20.1