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 => 9; |
4 |
use Test::More tests => 11; |
5 |
use Test::MockModule; |
5 |
use Test::MockModule; |
6 |
use MARC::Record; |
6 |
use MARC::Record; |
7 |
use MARC::Field; |
7 |
use MARC::Field; |
Lines 11-24
use C4::Biblio qw( AddBiblio );
Link Here
|
11 |
use C4::Context; |
11 |
use C4::Context; |
12 |
use C4::Record; |
12 |
use C4::Record; |
13 |
|
13 |
|
|
|
14 |
use t::lib::TestBuilder; |
15 |
|
14 |
my $dbh = C4::Context->dbh; |
16 |
my $dbh = C4::Context->dbh; |
15 |
$dbh->{AutoCommit} = 0; |
17 |
$dbh->{AutoCommit} = 0; |
16 |
$dbh->{RaiseError} = 1; |
18 |
$dbh->{RaiseError} = 1; |
17 |
|
19 |
|
|
|
20 |
my $builder = t::lib::TestBuilder->new; |
18 |
my $module_biblio = Test::MockModule->new('C4::Biblio'); |
21 |
my $module_biblio = Test::MockModule->new('C4::Biblio'); |
19 |
|
22 |
|
20 |
my $record = new_record(); |
23 |
my $record = new_record(); |
21 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, q|| ); |
24 |
my $frameworkcode = q||; |
|
|
25 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $frameworkcode ); |
22 |
$module_biblio->mock( 'GetMarcBiblio', sub{ $record } ); |
26 |
$module_biblio->mock( 'GetMarcBiblio', sub{ $record } ); |
23 |
|
27 |
|
24 |
my $csv_content = q(Title=245$a|Author=245$c|Subject=650$a); |
28 |
my $csv_content = q(Title=245$a|Author=245$c|Subject=650$a); |
Lines 88-93
is( $csv_output, q[Title
Link Here
|
88 |
], q|TT way: display first subfield a for first field 245 if indicator 1 == 1 for field 100 is set| ); |
92 |
], q|TT way: display first subfield a for first field 245 if indicator 1 == 1 for field 100 is set| ); |
89 |
|
93 |
|
90 |
|
94 |
|
|
|
95 |
my $authorised_value_1 = |
96 |
$builder->build( { source => 'AuthorisedValue', value => { category => 'MY_AV_1', authorised_value => 1, lib => 'This is an AV', lib_opac => 'This is an AV (opac)' } } ); |
97 |
my $authorised_value_2 = $builder->build( |
98 |
{ source => 'AuthorisedValue', value => { category => 'MY_AV_2', authorised_value => 2, lib => 'This is another AV', lib_opac => 'This is another AV (opac)' } } ); |
99 |
$dbh->do(q|DELETE FROM marc_subfield_structure WHERE tagfield=998 and ( tagsubfield='8' or tagsubfield='9')|); |
100 |
$builder->build( |
101 |
{ source => 'MarcSubfieldStructure', value => { authorised_value => $authorised_value_1->{category}, tagfield => 998, tagsubfield => '8', frameworkcode => $frameworkcode } } |
102 |
); |
103 |
$builder->build( |
104 |
{ source => 'MarcSubfieldStructure', value => { authorised_value => $authorised_value_2->{category}, tagfield => 998, tagsubfield => '9', frameworkcode => $frameworkcode } } |
105 |
); |
106 |
$csv_content = q(Title=245$a|AV1=998$8|AV2=998$9); |
107 |
my $csv_profile_id_8 = insert_csv_profile( { csv_content => $csv_content } ); |
108 |
$csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_8, 1, $csv ); |
109 |
is( $csv_output, q[Title|AV1|AV2 |
110 |
"The art of computer programming,The art of another title"|"This is an AV"|"This is another AV" |
111 |
], q|TT way: display first subfield a for first field 245 if indicator 1 == 1 for field 100 is set| |
112 |
); |
113 |
|
114 |
$csv_content = q(Title=245$a|AVs=998); |
115 |
my $csv_profile_id_9 = insert_csv_profile( { csv_content => $csv_content } ); |
116 |
$csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_9, 1, $csv ); |
117 |
is( $csv_output, q[Title|AVs |
118 |
"The art of computer programming,The art of another title"|"This is an AV,This is another AV" |
119 |
], q|TT way: display first subfield a for first field 245 if indicator 1 == 1 for field 100 is set| |
120 |
); |
121 |
|
122 |
|
123 |
|
91 |
sub insert_csv_profile { |
124 |
sub insert_csv_profile { |
92 |
my ( $params ) = @_; |
125 |
my ( $params ) = @_; |
93 |
my $csv_content = $params->{csv_content}; |
126 |
my $csv_content = $params->{csv_content}; |
Lines 139-144
sub new_record {
Link Here
|
139 |
c => 'GEN', |
172 |
c => 'GEN', |
140 |
d => '2001-06-25', |
173 |
d => '2001-06-25', |
141 |
), |
174 |
), |
|
|
175 |
MARC::Field->new( |
176 |
998, ' ', ' ', |
177 |
8 => 1, |
178 |
9 => 2, |
179 |
), |
142 |
); |
180 |
); |
143 |
$record->append_fields(@fields); |
181 |
$record->append_fields(@fields); |
144 |
return $record; |
182 |
return $record; |
145 |
- |
|
|