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

(-)a/Koha/Acquisition/Basket.pm (+13 lines)
Lines 20-25 package Koha::Acquisition::Basket; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Acquisition::BasketGroups;
23
24
24
use base qw( Koha::Object );
25
use base qw( Koha::Object );
25
26
Lines 45-50 sub bookseller { Link Here
45
    return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs );
46
    return Koha::Acquisition::Bookseller->_new_from_dbic( $bookseller_rs );
46
}
47
}
47
48
49
=head3 basket_group
50
51
Returns the basket group associated to this basket
52
53
=cut
54
55
sub basket_group {
56
    my ($self) = @_;
57
    my $basket_group_rs = $self->_result->basketgroupid;
58
    return unless $basket_group_rs;
59
    return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs );
60
}
48
61
49
=head3 effective_create_items
62
=head3 effective_create_items
50
63
(-)a/Koha/Acquisition/BasketGroup.pm (+44 lines)
Line 0 Link Here
1
package Koha::Acquisition::BasketGroup;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
22
use base qw( Koha::Object );
23
24
=head1 NAME
25
26
Koha::Acquisition::BasketGroup - Koha Basket group Object class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=cut
33
34
=head2 Internal methods
35
36
=head3 _type
37
38
=cut
39
40
sub _type {
41
    return 'Aqbasketgroup';
42
}
43
44
1;
(-)a/Koha/Acquisition/BasketGroups.pm (+49 lines)
Line 0 Link Here
1
package Koha::Acquisition::BasketGroups;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Koha::Database;
21
use Koha::Acquisition::BasketGroup;
22
23
use base qw( Koha::Objects );
24
25
=head1 NAME
26
27
Koha::Acquisition::BasketGroups - Koha Basket groups object set class
28
29
=head1 API
30
31
=head2 Internal methods
32
33
=head3 _type
34
35
=cut
36
37
sub _type {
38
    return 'Aqbasketgroup';
39
}
40
41
=head3 object_class
42
43
=cut
44
45
sub object_class {
46
    return 'Koha::Acquisition::BasketGroup';
47
}
48
49
1;
(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-3 / +31 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2017 Koha Development team
3
# Copyright 2018 Koha Development team
4
#
4
#
5
# This file is part of Koha
5
# This file is part of Koha
6
#
6
#
Lines 19-25 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
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
25
Lines 78-80 subtest 'create_items + effective_create_items tests' => sub { Link Here
78
78
79
    $schema->storage->txn_rollback;
79
    $schema->storage->txn_rollback;
80
};
80
};
81
- 
81
82
subtest 'basket_group' => sub {
83
    plan tests => 2;
84
85
    $schema->storage->txn_begin;
86
    my $b = $builder->build_object(
87
        {
88
            class => 'Koha::Acquisition::Baskets',
89
            value => { basketgroupid => undef }, # not linked to a basketgroupid
90
        }
91
    );
92
93
    my $basket = Koha::Acquisition::Baskets->find( $b->basketno );
94
    is( $basket->basket_group, undef,
95
        '->basket_group should return undef if not linked to a basket group');
96
97
    $b = $builder->build_object(
98
        {
99
            class => 'Koha::Acquisition::Baskets',
100
            # Will be linked to a basket group by TestBuilder
101
        }
102
    );
103
104
    $basket = Koha::Acquisition::Baskets->find( $b->basketno );
105
    is( ref( $basket->basket_group ), 'Koha::Acquisition::BasketGroup',
106
        '->basket_group should return a Koha::Acquisition::BasketGroup object if linked to a basket group');
107
108
    $schema->storage->txn_rollback;
109
};

Return to bug 20366