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

(-)a/t/db_dependent/ImportBatch.t (-2 / +48 lines)
Lines 4-10 use Modern::Perl; Link Here
4
4
5
use C4::Context;
5
use C4::Context;
6
6
7
use Test::More tests => 5;
7
use Test::More tests => 7;
8
8
9
BEGIN {
9
BEGIN {
10
        use_ok('C4::ImportBatch');
10
        use_ok('C4::ImportBatch');
Lines 70-72 delete $importbatch1->{num_items}; Link Here
70
70
71
is_deeply( $importbatch1, $sample_import_batch1,
71
is_deeply( $importbatch1, $sample_import_batch1,
72
    "GetImportBatch returns the right informations about $sample_import_batch1" );
72
    "GetImportBatch returns the right informations about $sample_import_batch1" );
73
- 
73
74
my $record = MARC::Record->new;
75
# FIXME Create another MARC::Record which won't be modified
76
# AddItemsToImportBiblio will remove the items field from the record passed in parameter.
77
my $original_record = MARC::Record->new;
78
$record->leader('03174nam a2200445 a 4500');
79
$original_record->leader('03174nam a2200445 a 4500');
80
my ($item_tag, $item_subfield) = C4::Biblio::GetMarcFromKohaField('items.itemnumber','');
81
my @fields = (
82
    MARC::Field->new(
83
        100, '1', ' ',
84
        a => 'Knuth, Donald Ervin',
85
        d => '1938',
86
    ),
87
    MARC::Field->new(
88
        245, '1', '4',
89
        a => 'The art of computer programming',
90
        c => 'Donald E. Knuth.',
91
    ),
92
    MARC::Field->new(
93
        650, ' ', '0',
94
        a => 'Computer programming.',
95
        9 => '462',
96
    ),
97
    MARC::Field->new(
98
        $item_tag, ' ', ' ',
99
        e => 'my edition',
100
        i => 'my item part',
101
    ),
102
    MARC::Field->new(
103
        $item_tag, ' ', ' ',
104
        e => 'my edition 2',
105
        i => 'my item part 2',
106
    ),
107
);
108
$record->append_fields(@fields);
109
$original_record->append_fields(@fields);
110
my $import_record_id = AddBiblioToBatch( $id_import_batch1, 0, $record, 'utf8', int(rand(99999)), 0 );
111
AddItemsToImportBiblio( $id_import_batch1, $import_record_id, $record, 0 );
112
113
my $record_from_import_biblio_with_items = C4::ImportBatch::GetRecordFromImportBiblio( $import_record_id, 'embed_items' );
114
$original_record->leader($record_from_import_biblio_with_items->leader());
115
is_deeply( $record_from_import_biblio_with_items, $original_record, 'GetRecordFromImportBiblio should return the record with items if specified' );
116
$original_record->delete_fields($original_record->field($item_tag)); #Remove items fields
117
my $record_from_import_biblio_without_items = C4::ImportBatch::GetRecordFromImportBiblio( $import_record_id );
118
$original_record->leader($record_from_import_biblio_without_items->leader());
119
is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecordFromImportBiblio should return the record without items by default' );

Return to bug 6520