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

(-)a/C4/Breeding.pm (-1 / +2 lines)
Lines 315-321 sub _handle_one_result { Link Here
315
        $row->{breedingid}   = $breedingid;
315
        $row->{breedingid}   = $breedingid;
316
        $row->{isbn}=_isbn_replace($row->{isbn});
316
        $row->{isbn}=_isbn_replace($row->{isbn});
317
        my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
317
        my $pref_newtags = C4::Context->preference('AdditionalFieldsInZ3950ResultSearch');
318
        $row = _add_custom_field_rowdata($row, $marcrecord, $pref_newtags);
318
        $row = _add_custom_field_rowdata( $row, $marcrecord, $pref_newtags );
319
    }
319
    }
320
    return ( $row, $error );
320
    return ( $row, $error );
321
}
321
}
Lines 347-352 sub _do_xslt_proc { Link Here
347
sub _add_custom_field_rowdata
347
sub _add_custom_field_rowdata
348
{
348
{
349
    my ( $row, $record, $pref_newtags ) = @_;
349
    my ( $row, $record, $pref_newtags ) = @_;
350
    $pref_newtags //= '';
350
    my $pref_flavour = C4::Context->preference('MarcFlavour');
351
    my $pref_flavour = C4::Context->preference('MarcFlavour');
351
352
352
    $pref_newtags =~ s/^\s+|\s+$//g;
353
    $pref_newtags =~ s/^\s+|\s+$//g;
(-)a/installer/data/mysql/atomicupdate/bug_28166.pl (-5 / +9 lines)
Lines 1-15 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
2
3
return {
3
return {
4
    bug_number => "28166",
4
    bug_number  => "28166",
5
    description => "Add system preference for additional columns for Z39.50 authority search results",
5
    description => "Add system preference for additional columns for Z39.50 authority search results",
6
    up => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
9
        # Do you stuffs here
10
        # Do you stuffs here
10
        $dbh->do(q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
11
        $dbh->do(
12
            q{INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
11
('AdditionalFieldsInZ3950ResultAuthSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of an authority Z39.50 search', 'Free')
13
('AdditionalFieldsInZ3950ResultAuthSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of an authority Z39.50 search', 'Free')
12
});
14
}
15
        );
16
13
        # Print useful stuff here
17
        # Print useful stuff here
14
        # sysprefs
18
        # sysprefs
15
        say $out "Added new system preference 'AdditionalFieldsInZ3950ResultAuthSearch'";
19
        say $out "Added new system preference 'AdditionalFieldsInZ3950ResultAuthSearch'";
(-)a/t/db_dependent/Breeding.t (-16 / +23 lines)
Lines 56-62 subtest '_do_xslt_proc' => sub { Link Here
56
};
56
};
57
#Group 4: testing _add_custom_field_rowdata (part of Z3950Search)
57
#Group 4: testing _add_custom_field_rowdata (part of Z3950Search)
58
subtest '_add_custom_field_rowdata' => sub {
58
subtest '_add_custom_field_rowdata' => sub {
59
    plan tests => 3;
59
    plan tests => 5;
60
    test_add_custom_field_rowdata();
60
    test_add_custom_field_rowdata();
61
};
61
};
62
62
Lines 237-264 sub test_do_xslt { Link Here
237
237
238
sub test_add_custom_field_rowdata {
238
sub test_add_custom_field_rowdata {
239
    my $row = {
239
    my $row = {
240
       biblionumber => 0,
240
        biblionumber => 0,
241
       server => "testServer",
241
        server       => "testServer",
242
       breedingid => 0,
242
        breedingid   => 0,
243
       title => "Just a title"
243
        title        => "Just a title"
244
   };
244
    };
245
245
246
    my $biblio = MARC::Record->new();
246
    my $biblio = MARC::Record->new();
247
    $biblio->append_fields(
247
    $biblio->append_fields(
248
        MARC::Field->new('245', ' ', ' ', a => 'Just a title'),
248
        MARC::Field->new( '245', ' ', ' ', a => 'Just a title' ),
249
        MARC::Field->new('035', ' ', ' ', a => 'First 035'),
249
        MARC::Field->new( '035', ' ', ' ', a => 'First 035' ),
250
        MARC::Field->new('035', ' ', ' ', a => 'Second 035')
250
        MARC::Field->new( '035', ' ', ' ', a => 'Second 035' )
251
    );
251
    );
252
252
253
   t::lib::Mocks::mock_preference('AdditionalFieldsInZ3950ResultSearch',"245\$a, 035\$a");
253
    my $pref_newtags = "245\$a, 035\$a";
254
254
255
   my $returned_row = C4::Breeding::_add_custom_field_rowdata($row, $biblio);
255
    my $returned_row = C4::Breeding::_add_custom_field_rowdata( $row, $biblio, $pref_newtags );
256
257
    is( $returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio" );
258
    is(
259
        $returned_row->{addnumberfields}[0], "245\$a",
260
        "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference"
261
    );
256
262
257
   is($returned_row->{title}, "Just a title", "_add_rowdata returns the title of a biblio");
263
    # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_field_row_data
258
   is($returned_row->{addnumberfields}[0], "245\$a", "_add_rowdata returns the field number chosen in the AdditionalFieldsInZ3950ResultSearch preference");
264
    is_deeply( \$returned_row->{"035\$a"}, \[ "First 035 ", "Second 035 " ], "_add_rowdata supports repeatable tags" );
259
265
260
   # Test repeatble tags,the trailing whitespace is a normal side-effect of _add_custom_field_row_data
266
    warning_is { C4::Breeding::_add_custom_field_rowdata( $row, $biblio, undef ) } undef,
261
   is_deeply(\$returned_row->{"035\$a"}, \["First 035 ", "Second 035 "],"_add_rowdata supports repeatable tags");
267
        'no warn from add_custom_field_rowdata when pref_newtags undef';
268
    warning_is { C4::Breeding::_add_custom_field_rowdata( $row, $biblio, "" ) } undef,
269
        'no warn from add_custom_field_rowdata when pref_newtags blank';
262
}
270
}
263
271
264
sub xsl_file {
272
sub xsl_file {
265
- 

Return to bug 28166