Lines 1-5
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
use Test::More tests => 6; |
2 |
use Test::More tests => 12; |
3 |
use Test::MockModule; |
3 |
use Test::MockModule; |
4 |
|
4 |
|
5 |
use MARC::Record; |
5 |
use MARC::Record; |
Lines 26-32
$biblio_module->mock(
Link Here
|
26 |
|
26 |
|
27 |
# default value for an existing field |
27 |
# default value for an existing field |
28 |
'245' => { |
28 |
'245' => { |
29 |
c => { defaultvalue => $default_author }, |
29 |
c => { defaultvalue => $default_author, mandatory => 1 }, |
30 |
mandatory => 0, |
30 |
mandatory => 0, |
31 |
repeatable => 0, |
31 |
repeatable => 0, |
32 |
tab => 0, |
32 |
tab => 0, |
Lines 37-42
$biblio_module->mock(
Link Here
|
37 |
'099' => { |
37 |
'099' => { |
38 |
x => { defaultvalue => $default_x }, |
38 |
x => { defaultvalue => $default_x }, |
39 |
}, |
39 |
}, |
|
|
40 |
'942' => { |
41 |
c => { defaultvalue => 'BK', mandatory => 1 }, |
42 |
d => { defaultvalue => '942d_val' }, |
43 |
f => { defaultvalue => '942f_val' }, |
44 |
}, |
40 |
}; |
45 |
}; |
41 |
} |
46 |
} |
42 |
); |
47 |
); |
Lines 96-99
$record->field('008')->update( undef );
Link Here
|
96 |
C4::Acquisition::FillWithDefaultValues($record); |
101 |
C4::Acquisition::FillWithDefaultValues($record); |
97 |
is( $record->field('008')->data, $default_x, 'Controlfield got default' ); |
102 |
is( $record->field('008')->data, $default_x, 'Controlfield got default' ); |
98 |
|
103 |
|
|
|
104 |
is( $record->subfield('942','d'), '942d_val', 'Check 942d' ); |
105 |
|
106 |
# Now test only_mandatory parameter |
107 |
$record->delete_fields( $record->field('245') ); |
108 |
$record->delete_fields( $record->field('942') ); |
109 |
$record->append_fields( MARC::Field->new('942','','','f'=>'f val') ); |
110 |
# We deleted 245 and replaced 942. If we only apply mandatories, we should get |
111 |
# back 245c again and 942c but not 942d. 942f should be left alone. |
112 |
C4::Acquisition::FillWithDefaultValues($record, { only_mandatory => 1 }); |
113 |
@fields_245 = $record->field(245); |
114 |
is( scalar @fields_245, 1, 'Only one 245 expected' ); |
115 |
is( $record->subfield('245','c'), $default_author, '245c restored' ); |
116 |
is( $record->subfield('942','c'), 'BK', '942c also restored' ); |
117 |
is( $record->subfield('942','d'), undef, '942d should not be there' ); |
118 |
is( $record->subfield('942','f'), 'f val', '942f untouched' ); |
119 |
|
99 |
$schema->storage->txn_rollback; |
120 |
$schema->storage->txn_rollback; |
100 |
- |
|
|