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

(-)a/t/db_dependent/ImportBatch.t (-2 / +46 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 328-333 subtest "_get_commit_action" => sub { Link Here
328
328
329
};
329
};
330
330
331
subtest "Do not adjust biblionumber when replacing items during import" => sub {
332
    plan tests => 6;
333
334
    my $item1 = $builder->build_sample_item;
335
    my $item2 = $builder->build_sample_item;
336
337
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
338
339
    my $import_item = $builder->build_object({ class => 'Koha::Import::Record::Items', value => {
340
        marcxml => qq{<?xml version="1.0" encoding="UTF-8"?>
341
<collection
342
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
343
  xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
344
  xmlns="http://www.loc.gov/MARC21/slim">
345
346
<record>
347
  <leader>00000    a              </leader>
348
  <datafield tag="952" ind1=" " ind2=" ">
349
    <subfield code="a">${\($library->branchcode)}</subfield>
350
    <subfield code="b">${\($library->branchcode)}</subfield>
351
    <subfield code="c">GEN</subfield>
352
    <subfield code="p">${\($item1->barcode)}</subfield>
353
    <subfield code="y">BK</subfield>
354
  </datafield>
355
</record>
356
</collection>
357
        },
358
    }});
359
360
    isnt( $item1->homebranch, $library->branchcode, "Item's homebranch is currently not the same as our created branch's branchcode" );
361
362
    my ( $num_items_added, $num_items_replaced, $num_items_errored ) =
363
        C4::ImportBatch::_batchCommitItems( $import_item->import_record_id, $item2->biblionumber, 'replace' );
364
365
    $item1->discard_changes();
366
367
    is( $num_items_errored, 0, 'Item was replaced' );
368
    $import_item->discard_changes();
369
    is( $import_item->status, 'imported', 'Import was successful');
370
    is( $import_item->import_error, undef, 'No error was reported' );
371
372
    is( $item1->biblionumber, $item1->biblioitemnumber, "Item's biblionumber and biblioitemnumber match" );
373
    is( $item1->homebranch, $library->branchcode, "Item was overlayed succesfully" );
374
};
375
331
sub get_import_record {
376
sub get_import_record {
332
    my $id_import_batch = shift;
377
    my $id_import_batch = shift;
333
    return $dbh->do('SELECT * FROM import_records WHERE import_batch_id = ?', undef, $id_import_batch);
378
    return $dbh->do('SELECT * FROM import_records WHERE import_batch_id = ?', undef, $id_import_batch);
334
- 

Return to bug 32804