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

(-)a/Koha/Authority.pm (-8 / +20 lines)
Lines 95-102 sub controlled_indicators { Link Here
95
        ? 'UNIMARCAUTH'
95
        ? 'UNIMARCAUTH'
96
        : 'MARC21';
96
        : 'MARC21';
97
    if( !$record ) {
97
    if( !$record ) {
98
        $record = MARC::Record->new_from_xml(
98
        $record = $self->record;
99
            $self->marcxml, 'UTF-8', $flavour );
100
    }
99
    }
101
100
102
    if( !$self->{_report_tag} ) {
101
    if( !$self->{_report_tag} ) {
Lines 125-136 Return a list of identifiers of the authors which are in 024$2$a Link Here
125
sub get_identifiers {
124
sub get_identifiers {
126
    my ( $self, $params ) = @_;
125
    my ( $self, $params ) = @_;
127
126
128
    my $flavour =
127
    my $record = $self->record;
129
      C4::Context->preference('marcflavour') eq 'UNIMARC'
130
      ? 'UNIMARCAUTH'
131
      : 'MARC21';
132
    my $record =
133
      MARC::Record->new_from_xml( $self->marcxml, 'UTF-8', $flavour );
134
128
135
    my @identifiers;
129
    my @identifiers;
136
    for my $field ( $record->field('024') ) {
130
    for my $field ( $record->field('024') ) {
Lines 143-148 sub get_identifiers { Link Here
143
    return \@identifiers;
137
    return \@identifiers;
144
}
138
}
145
139
140
=head3 record
141
142
    my $record = $authority->record()
143
144
Return the MARC::Record for this authority
145
146
=cut
147
148
sub record {
149
    my ( $self ) = @_;
150
151
    my $flavour =
152
      C4::Context->preference('marcflavour') eq 'UNIMARC'
153
      ? 'UNIMARCAUTH'
154
      : 'MARC21';
155
    return MARC::Record->new_from_xml( $self->marcxml, 'UTF-8', $flavour );
156
}
157
146
=head2 Class Methods
158
=head2 Class Methods
147
159
148
=head3 type
160
=head3 type
(-)a/t/db_dependent/Koha/Authorities.t (-2 / +37 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 8;
22
use Test::More tests => 9;
23
use MARC::Field;
23
use MARC::Field;
24
use MARC::File::XML;
24
use MARC::File::XML;
25
use MARC::Record;
25
use MARC::Record;
Lines 285-288 subtest 'get_identifiers' => sub { Link Here
285
    );
285
    );
286
};
286
};
287
287
288
subtest 'record tests' => sub {
289
    plan tests => 3;
290
291
    t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' );
292
    my $record = MARC::Record->new();
293
    $record->add_fields(
294
        [
295
            '100', ' ', ' ',
296
            a => 'Lastname, Firstname',
297
            b => 'b',
298
            c => 'c',
299
            i => 'i'
300
        ],
301
        [
302
            '024', '', '',
303
            a => '0000-0002-1234-5678',
304
            2 => 'orcid',
305
            6 => 'https://orcid.org/0000-0002-1234-5678'
306
        ],
307
        [
308
            '024', '', '',
309
            a => '01234567890',
310
            2 => 'scopus',
311
            6 => 'https://www.scopus.com/authid/detail.uri?authorId=01234567890'
312
        ],
313
    );
314
    my $authid = C4::AuthoritiesMarc::AddAuthority($record, undef, 'PERSO_NAME');
315
    my $authority = Koha::Authorities->find($authid);
316
    my $authority_record = $authority->record;
317
    is ($authority_record->field('100')->subfield('a'), 'Lastname, Firstname');
318
    my @fields_024 = $authority_record->field('024');
319
    is ($fields_024[0]->subfield('a'), '0000-0002-1234-5678');
320
    is ($fields_024[1]->subfield('a'), '01234567890');
321
322
};
323
288
$schema->storage->txn_rollback;
324
$schema->storage->txn_rollback;
289
- 

Return to bug 35343