View | Details | Raw Unified | Return to bug 30831
Collapse All | Expand All

(-)a/t/db_dependent/ImportBatch.t (-2 / +34 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 18;
4
use Test::More tests => 19;
5
use utf8;
5
use utf8;
6
use File::Basename;
6
use File::Basename;
7
use File::Temp qw/tempfile/;
7
use File::Temp qw/tempfile/;
Lines 183-188 C4::ImportBatch::DeleteBatch( $id_import_batch3 ); Link Here
183
my $import_batch = C4::ImportBatch::GetImportBatch( $id_import_batch3 );
183
my $import_batch = C4::ImportBatch::GetImportBatch( $id_import_batch3 );
184
is( $import_batch, undef, "Batch 3 has been deleted");
184
is( $import_batch, undef, "Batch 3 has been deleted");
185
185
186
subtest "BatchCommitItems" => sub {
187
    plan tests => 3;
188
189
    my $exist_item = $builder->build_sample_item;
190
    my $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => {
191
        marcxml => q{<?xml version="1.0" encoding="UTF-8"?>
192
<collection
193
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
194
  xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
195
  xmlns="http://www.loc.gov/MARC21/slim">
196
197
<record>
198
  <leader>00000    a              </leader>
199
  <datafield tag="952" ind1=" " ind2=" ">
200
    <subfield code="a">CPL</subfield>
201
    <subfield code="b">CPL</subfield>
202
    <subfield code="c">GEN</subfield>
203
    <subfield code="p">}.$exist_item->barcode.q{</subfield>
204
    <subfield code="y">BK</subfield>
205
  </datafield>
206
</record>
207
</collection>
208
        },
209
    }});
210
211
    my ( $num_items_added, $num_items_replaced, $num_items_errored ) =
212
        C4::ImportBatch::BatchCommitItems( $import_item->import_record_id, 32, 'always_add',64 );
213
    is( $num_items_errored, 1, "Item with duplicate barcode fails when action always_add" );
214
    $import_item->discard_changes();
215
    is( $import_item->status, 'error', "Import item marked as error when duplicate barcode and action always_add");
216
    is( $import_item->import_error, 'duplicate item barcode', 'Error correctly set when import item has duplciate barcode and action always_add' );
217
};
218
186
subtest "RecordsFromMarcPlugin" => sub {
219
subtest "RecordsFromMarcPlugin" => sub {
187
    plan tests => 5;
220
    plan tests => 5;
188
221
189
- 

Return to bug 30831