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

(-)a/Koha/Authority.pm (-6 / +16 lines)
Lines 19-31 package Koha::Authority; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Carp;
23
24
use Koha::Database;
25
use C4::Context;
26
use MARC::Record;
27
28
use base qw(Koha::Object);
22
use base qw(Koha::Object);
23
use Koha::AuthorityMergeRequest;
29
24
30
=head1 NAME
25
=head1 NAME
31
26
Lines 33-38 Koha::Authority - Koha Authority Object class Link Here
33
28
34
=head1 API
29
=head1 API
35
30
31
=head2 Instance Methods
32
33
=cut
34
35
=head3 add_merge_request
36
37
=cut
38
39
sub add_merge_request {
40
    my ( $self ) = @_;
41
    if( $self->in_storage ) {
42
        Koha::AuthorityMergeRequest->new({ authid => $self->authid })->store;
43
    }
44
}
45
36
=head2 Class Methods
46
=head2 Class Methods
37
47
38
=cut
48
=cut
(-)a/Koha/AuthorityMergeRequest.pm (+60 lines)
Line 0 Link Here
1
package Koha::AuthorityMergeRequest;
2
3
# Copyright Rijksmuseum 2017
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use parent qw(Koha::Object);
23
24
=head1 NAME
25
26
Koha::AuthorityMergeRequest - Koha::Object class for single need_merge_authorities record
27
28
=head1 SYNOPSIS
29
30
use Koha::AuthorityMergeRequest;
31
32
=head1 DESCRIPTION
33
34
Description
35
36
=head1 METHODS
37
38
=head2 INSTANCE METHODS
39
40
=head2 CLASS METHODS
41
42
=head3 _type
43
44
Returns name of corresponding DBIC resultset
45
46
=cut
47
48
sub _type {
49
    return 'NeedMergeAuthority';
50
}
51
52
=head1 AUTHOR
53
54
Marcel de Rooy (Rijksmuseum)
55
56
Koha Development Team
57
58
=cut
59
60
1;
(-)a/Koha/AuthorityMergeRequests.pm (+72 lines)
Line 0 Link Here
1
package Koha::AuthorityMergeRequests;
2
3
# Copyright Rijksmuseum 2017
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::AuthorityMergeRequest;
23
24
use parent qw(Koha::Objects);
25
26
=head1 NAME
27
28
Koha::AuthorityMergeRequests - Koha::Objects class for need_merge_authorities
29
30
=head1 SYNOPSIS
31
32
use Koha::AuthorityMergeRequests;
33
34
=head1 DESCRIPTION
35
36
Description
37
38
=head1 METHODS
39
40
=head2 INSTANCE METHODS
41
42
=head2 CLASS METHODS
43
44
=head3 _type
45
46
Returns name of corresponding DBIC resultset
47
48
=cut
49
50
sub _type {
51
    return 'NeedMergeAuthority';
52
}
53
54
=head3 object_class
55
56
Returns name of corresponding Koha object class
57
58
=cut
59
60
sub object_class {
61
    return 'Koha::AuthorityMergeRequest';
62
}
63
64
=head1 AUTHOR
65
66
Marcel de Rooy (Rijksmuseum)
67
68
Koha Development Team
69
70
=cut
71
72
1;
(-)a/t/db_dependent/Koha/Authorities.t (-3 / +18 lines)
Lines 19-28 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
23
24
use Koha::Authority;
24
use Koha::Authority;
25
use Koha::Authorities;
25
use Koha::Authorities;
26
use Koha::AuthorityMergeRequests;
26
use Koha::Authority::Type;
27
use Koha::Authority::Type;
27
use Koha::Authority::Types;
28
use Koha::Authority::Types;
28
use Koha::Database;
29
use Koha::Database;
Lines 51-55 is( Koha::Authorities->search->count, $nb_of_authorities + 2, 'The 2 au Link Here
51
$new_authority_1->delete;
52
$new_authority_1->delete;
52
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the library' );
53
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the library' );
53
54
55
subtest 'Add merge request' => sub {
56
    plan tests => 2;
57
58
    my $count = Koha::AuthorityMergeRequests->count;
59
    $new_authority_2->add_merge_request;
60
    is( Koha::AuthorityMergeRequests->count,
61
        $count+1,
62
        'Merge request added' );
63
    my $new_authority_3 = Koha::Authority->new;
64
    $new_authority_3->add_merge_request;
65
    is( Koha::AuthorityMergeRequests->count,
66
        $count+1,
67
        'No additional merge request added (not in storage)' );
68
69
};
70
54
$schema->storage->txn_rollback;
71
$schema->storage->txn_rollback;
55
1;
56
- 

Return to bug 9988