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

(-)a/C4/AuthoritiesMarc.pm (-1 / +3 lines)
Lines 687-692 sub AddAuthority { Link Here
687
    } else {
687
    } else {
688
        $action    = 'modify';
688
        $action    = 'modify';
689
        $authority = Koha::Authorities->find($authid);
689
        $authority = Koha::Authorities->find($authid);
690
        $authority->authtypecode($authtypecode);
691
        # In the case we are changing type we need to set this to ensure heading field is correctly chosen
690
    }
692
    }
691
693
692
    # Insert/update the recordID in MARC record
694
    # Insert/update the recordID in MARC record
Lines 701-707 sub AddAuthority { Link Here
701
            authtypecode => $authtypecode,
703
            authtypecode => $authtypecode,
702
            marc         => $record->as_usmarc,
704
            marc         => $record->as_usmarc,
703
            marcxml      => $record->as_xml_record($format),
705
            marcxml      => $record->as_xml_record($format),
704
            heading      => $heading->display_form,
706
            heading      => $heading ? $heading->display_form : '',
705
        }
707
        }
706
    );
708
    );
707
709
(-)a/C4/Heading.pm (+1 lines)
Lines 66-71 sub new_from_field { Link Here
66
    my $marcflavour   = C4::Context->preference('marcflavour');
66
    my $marcflavour   = C4::Context->preference('marcflavour');
67
    my $marc_handler = _marc_format_handler($marcflavour);
67
    my $marc_handler = _marc_format_handler($marcflavour);
68
68
69
    return unless $field;
69
    my $tag = $field->tag();
70
    my $tag = $field->tag();
70
    return unless $marc_handler->valid_heading_tag( $tag, $frameworkcode, $auth );
71
    return unless $marc_handler->valid_heading_tag( $tag, $frameworkcode, $auth );
71
    my $self = {};
72
    my $self = {};
(-)a/t/db_dependent/Authority/Merge.t (-1 / +9 lines)
Lines 33-38 t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ) if $marcflavour; Link Here
33
my $schema  = Koha::Database->new->schema;
33
my $schema  = Koha::Database->new->schema;
34
$schema->storage->txn_begin;
34
$schema->storage->txn_begin;
35
35
36
my $heading_module = Test::MockModule->new('C4::Heading::MARC21');
37
$heading_module->mock(
38
    'valid_heading_tag',
39
    sub {
40
        return 1;
41
    }
42
);
43
36
# Global variables, mocking and framework modifications
44
# Global variables, mocking and framework modifications
37
our @linkedrecords;
45
our @linkedrecords;
38
my $mocks = set_mocks();
46
my $mocks = set_mocks();
Lines 183-189 subtest 'Test merge A1 to B1 (changing authtype)' => sub { Link Here
183
    my $authid1 = AddAuthority( $auth1, undef, $authtype1 );
191
    my $authid1 = AddAuthority( $auth1, undef, $authtype1 );
184
    my $auth2 = MARC::Record->new;
192
    my $auth2 = MARC::Record->new;
185
    $auth2->append_fields( MARC::Field->new( '112', '0', '0', 'a' => 'Batman', c => 'cc' ));
193
    $auth2->append_fields( MARC::Field->new( '112', '0', '0', 'a' => 'Batman', c => 'cc' ));
186
    my $authid2 = AddAuthority($auth1, undef, $authtype2 );
194
    my $authid2 = AddAuthority($auth2, undef, $authtype2 );
187
195
188
    # create a biblio with one 109 and two 609s to be touched
196
    # create a biblio with one 109 and two 609s to be touched
189
    # seems exceptional see bug 13760 comment10
197
    # seems exceptional see bug 13760 comment10
(-)a/t/db_dependent/Biblio.t (+4 lines)
Lines 643-648 subtest 'UNIMARC' => sub { Link Here
643
    # Mock the auth type data for UNIMARC
643
    # Mock the auth type data for UNIMARC
644
    $dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr;
644
    $dbh->do("UPDATE auth_types SET auth_tag_to_report = '106' WHERE auth_tag_to_report = '100'") or die $dbh->errstr;
645
645
646
    $dbh->do(
647
        "UPDATE marc_subfield_structure SET tagfield = '106' WHERE authtypecode = 'PERSO_NAME' AND frameworkcode='' AND tagfield='100' "
648
    ) or die $dbh->errstr;
649
646
    run_tests('UNIMARC');
650
    run_tests('UNIMARC');
647
    $schema->storage->txn_rollback;
651
    $schema->storage->txn_rollback;
648
    $schema->storage->txn_begin;
652
    $schema->storage->txn_begin;
(-)a/t/db_dependent/Koha/Authorities.t (+6 lines)
Lines 187-192 unimarc,*,ind1:auth2,ind2:auth1|); Link Here
187
    $record = MARC::Record->new;
187
    $record = MARC::Record->new;
188
    $record->append_fields( MARC::Field->new( '210', '1', '2', a => 'Name' ) );
188
    $record->append_fields( MARC::Field->new( '210', '1', '2', a => 'Name' ) );
189
    $type = $builder->build({ source => 'AuthType', value => { auth_tag_to_report => '210'} });
189
    $type = $builder->build({ source => 'AuthType', value => { auth_tag_to_report => '210'} });
190
    my $dbh = C4::Context->dbh;
191
    $dbh->do(
192
        "INSERT INTO marc_subfield_structure (tagfield,authtypecode,frameworkcode) VALUES ('210',?,'')", undef,
193
        $type->{authtypecode}
194
    ) or die $dbh->errstr;
195
190
    $authid = C4::AuthoritiesMarc::AddAuthority( $record, undef, $type->{authtypecode} );
196
    $authid = C4::AuthoritiesMarc::AddAuthority( $record, undef, $type->{authtypecode} );
191
    $auth = Koha::Authorities->find( $authid );
197
    $auth = Koha::Authorities->find( $authid );
192
    is( $auth->controlled_indicators({ biblio_tag => '345' })->{ind1}, '2', 'UNIMARC: Swapped ind2' );
198
    is( $auth->controlled_indicators({ biblio_tag => '345' })->{ind1}, '2', 'UNIMARC: Swapped ind2' );
(-)a/t/db_dependent/Koha/Plugins/authority_hooks.t (-2 / +6 lines)
Lines 53-63 subtest 'after_authority_action hook' => sub { Link Here
53
    my $plugin = Koha::Plugin::Test->new->enable;
53
    my $plugin = Koha::Plugin::Test->new->enable;
54
    my $id;
54
    my $id;
55
55
56
    warnings_exist { ( $id ) = C4::AuthoritiesMarc::AddAuthority( MARC::Record->new, undef, 'PERSO_NAME' ); }
56
    my $record = MARC::Record->new;
57
    $record->append_fields( MARC::Field->new( '100', '1', '2', a => 'Name' ) );
58
    my $type = $builder->build( { source => 'AuthType', value => { auth_tag_to_report => '100' } } );
59
60
    warnings_exist { ( $id ) = C4::AuthoritiesMarc::AddAuthority( $record, undef, $type->{authtypecode} ); }
57
            qr/after_authority_action called with action: create, id: \d+/,
61
            qr/after_authority_action called with action: create, id: \d+/,
58
            'AddAuthority calls the hook with action=create, id passed';
62
            'AddAuthority calls the hook with action=create, id passed';
59
63
60
    warnings_exist { C4::AuthoritiesMarc::ModAuthority( $id, MARC::Record->new, 'PERSO_NAME', { skip_merge => 1 } ); }
64
    warnings_exist { C4::AuthoritiesMarc::ModAuthority( $id, $record, $type->{authtypecode}, { skip_merge => 1 } ); }
61
            qr/after_authority_action called with action: modify, id: $id/,
65
            qr/after_authority_action called with action: modify, id: $id/,
62
            'ModAuthority calls the hook with action=modify, id passed';
66
            'ModAuthority calls the hook with action=modify, id passed';
63
67
(-)a/t/db_dependent/api/v1/authorities.t (-5 / +18 lines)
Lines 252-267 subtest 'put() tests' => sub { Link Here
252
    $patron->set_password( { password => $password, skip_validation => 1 } );
252
    $patron->set_password( { password => $password, skip_validation => 1 } );
253
    my $userid = $patron->userid;
253
    my $userid = $patron->userid;
254
254
255
    my $authority = $builder->build_object({ 'class' => 'Koha::Authorities', value => {
255
    my $authority_type = $builder->build_object(
256
      marcxml => q|<?xml version="1.0" encoding="UTF-8"?>
256
        {
257
            'class' => 'Koha::Authority::Types',
258
            value   => {
259
                auth_tag_to_report => '110',
260
            }
261
        }
262
    );
263
    my $authority = $builder->build_object(
264
        {
265
            'class' => 'Koha::Authorities',
266
            value   => {
267
                marcxml => q|<?xml version="1.0" encoding="UTF-8"?>
257
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
268
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
258
    <controlfield tag="001">1001</controlfield>
269
    <controlfield tag="001">1001</controlfield>
259
    <datafield tag="110" ind1=" " ind2=" ">
270
    <datafield tag="110" ind1=" " ind2=" ">
260
        <subfield code="9">102</subfield>
271
        <subfield code="9">102</subfield>
261
        <subfield code="a">My Corporation</subfield>
272
        <subfield code="a">My Corporation</subfield>
262
    </datafield>
273
    </datafield>
263
</record>|
274
</record>|,
264
    } });
275
                authtypecode => $authority_type->authtypecode,
276
            }
277
        }
278
    );
265
279
266
    my $authid       = $authority->id;
280
    my $authid       = $authority->id;
267
    my $authtypecode = $authority->authtypecode;
281
    my $authtypecode = $authority->authtypecode;
268
- 

Return to bug 30047