Lines 19-24
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use Test::More tests => 5; |
20 |
use Test::More tests => 5; |
21 |
use Test::Exception; |
21 |
use Test::Exception; |
|
|
22 |
use Test::MockModule; |
22 |
use Test::Warn; |
23 |
use Test::Warn; |
23 |
|
24 |
|
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
Lines 36-42
my $builder = t::lib::TestBuilder->new;
Link Here
|
36 |
|
37 |
|
37 |
subtest 'record() tests' => sub { |
38 |
subtest 'record() tests' => sub { |
38 |
|
39 |
|
39 |
plan tests => 9; |
40 |
plan tests => 11; |
40 |
|
41 |
|
41 |
$schema->storage->txn_begin; |
42 |
$schema->storage->txn_begin; |
42 |
|
43 |
|
Lines 45-56
subtest 'record() tests' => sub {
Link Here
|
45 |
# Create a valid record |
46 |
# Create a valid record |
46 |
my $record = MARC::Record->new(); |
47 |
my $record = MARC::Record->new(); |
47 |
my $field = MARC::Field->new( '245', '', '', 'a' => $title ); |
48 |
my $field = MARC::Field->new( '245', '', '', 'a' => $title ); |
48 |
$record->append_fields($field); |
49 |
my $f952_1 = MARC::Field->new( |
|
|
50 |
'952', '', '', 0 => '1', |
51 |
y => 'BK', |
52 |
c => 'GEN', |
53 |
d => '2001-06-25', |
54 |
); |
55 |
my $f952_2 = MARC::Field->new( |
56 |
'952', '', '', 0 => '1', |
57 |
y => 'BK', |
58 |
c => 'GEN', |
59 |
d => '2001-06-25', |
60 |
); |
61 |
$record->append_fields( $field, $f952_1, $f952_2 ); |
49 |
my ($biblio_id) = C4::Biblio::AddBiblio( $record, '' ); |
62 |
my ($biblio_id) = C4::Biblio::AddBiblio( $record, '' ); |
50 |
|
63 |
|
|
|
64 |
my @fields_952 = $record->field('952'); |
65 |
is( scalar @fields_952, 2, 'The record to be inserted contains 2 item fields' ); |
66 |
|
67 |
my $c4_biblio = Test::MockModule->new('C4::Biblio'); |
68 |
$c4_biblio->mock( 'GetMarcFromKohaField', sub { return '952'; } ); |
69 |
|
51 |
my $metadata = Koha::Biblios->find($biblio_id)->metadata; |
70 |
my $metadata = Koha::Biblios->find($biblio_id)->metadata; |
52 |
my $record2 = $metadata->record; |
71 |
my $record2 = $metadata->record; |
53 |
|
72 |
|
|
|
73 |
@fields_952 = $record2->field('952'); |
74 |
is( scalar @fields_952, 0, 'Item fields stripped out then calling $metadata->record' ); |
75 |
|
54 |
is( ref $record2, 'MARC::Record', 'Method record() returned a MARC::Record object' ); |
76 |
is( ref $record2, 'MARC::Record', 'Method record() returned a MARC::Record object' ); |
55 |
is( $record2->field('245')->subfield("a"), |
77 |
is( $record2->field('245')->subfield("a"), |
56 |
$title, 'Title in 245$a matches title from original record object' ); |
78 |
$title, 'Title in 245$a matches title from original record object' ); |
57 |
- |
|
|