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

(-)a/Koha/Checkout.pm (-24 lines)
Lines 1-7 Link Here
1
package Koha::Checkout;
1
package Koha::Checkout;
2
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Koha is free software; you can redistribute it and/or modify it under the
Lines 19-52 package Koha::Checkout; Link Here
19
17
20
use Modern::Perl;
18
use Modern::Perl;
21
19
22
use Carp;
23
24
use Koha::Database;
20
use Koha::Database;
25
21
26
use base qw(Koha::Object);
22
use base qw(Koha::Object);
27
23
28
=head1 NAME
29
30
Koha::Checkout - Koha Checkout object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
24
sub _type {
43
    return 'Issue';
25
    return 'Issue';
44
}
26
}
45
27
46
=head1 AUTHOR
47
48
Kyle M Hall <kyle@bywatersolutions.com>
49
50
=cut
51
52
1;
28
1;
(-)a/Koha/Checkouts.pm (-29 lines)
Lines 1-7 Link Here
1
package Koha::Checkouts;
1
package Koha::Checkouts;
2
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
3
# This file is part of Koha.
6
#
4
#
7
# Koha is free software; you can redistribute it and/or modify it under the
5
# Koha is free software; you can redistribute it and/or modify it under the
Lines 19-62 package Koha::Checkouts; Link Here
19
17
20
use Modern::Perl;
18
use Modern::Perl;
21
19
22
use Carp;
23
24
use Koha::Database;
20
use Koha::Database;
25
26
use Koha::Checkout;
21
use Koha::Checkout;
27
22
28
use base qw(Koha::Objects);
23
use base qw(Koha::Objects);
29
24
30
=head1 NAME
31
32
Koha::Checkouts - Koha Checkout object set class
33
34
=head1 API
35
36
=head2 Class Methods
37
38
=cut
39
40
=head3 type
41
42
=cut
43
44
sub _type {
25
sub _type {
45
    return 'Issue';
26
    return 'Issue';
46
}
27
}
47
28
48
=head3 object_class
49
50
=cut
51
52
sub object_class {
29
sub object_class {
53
    return 'Koha::Checkout';
30
    return 'Koha::Checkout';
54
}
31
}
55
32
56
=head1 AUTHOR
57
58
Kyle M Hall <kyle@bywatersolutions.com>
59
60
=cut
61
62
1;
33
1;
(-)a/Koha/Issue.pm (-28 lines)
Lines 1-28 Link Here
1
package Koha::Issue;
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
sub _type {
25
    return 'Issue';
26
}
27
28
1;
(-)a/Koha/Issues.pm (-33 lines)
Lines 1-33 Link Here
1
package Koha::Issues;
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::Issue;
22
23
use base qw(Koha::Objects);
24
25
sub _type {
26
    return 'Issue';
27
}
28
29
sub object_class {
30
    return 'Koha::Issue';
31
}
32
33
1;
(-)a/t/db_dependent/Koha/Checkouts.t (-16 / +13 lines)
Lines 30-62 use t::lib::TestBuilder; Link Here
30
my $schema = Koha::Database->new->schema;
30
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
31
$schema->storage->txn_begin;
32
32
33
my $builder         = t::lib::TestBuilder->new;
33
my $builder      = t::lib::TestBuilder->new;
34
my $library         = $builder->build( { source => 'Branch' } );
34
my $patron       = $builder->build( { source => 'Borrower' } );
35
my $patron          = $builder->build( { source => 'Borrower', value => { branchcode => $library->{branchcode} } } );
35
my $item_1       = $builder->build( { source => 'Item' } );
36
my $item_1          = $builder->build( { source => 'Item' } );
36
my $item_2       = $builder->build( { source => 'Item' } );
37
my $item_2          = $builder->build( { source => 'Item' } );
37
my $nb_of_issues = Koha::Checkouts->search->count;
38
my $nb_of_checkouts = Koha::Checkouts->search->count;
38
my $new_issue_1  = Koha::Checkout->new(
39
my $new_checkout_1  = Koha::Checkout->new(
40
    {   borrowernumber => $patron->{borrowernumber},
39
    {   borrowernumber => $patron->{borrowernumber},
41
        itemnumber     => $item_1->{itemnumber},
40
        itemnumber     => $item_1->{itemnumber},
42
        branchcode     => $library->{branchcode},
43
    }
41
    }
44
)->store;
42
)->store;
45
my $new_checkout_2 = Koha::Checkout->new(
43
my $new_issue_2 = Koha::Checkout->new(
46
    {   borrowernumber => $patron->{borrowernumber},
44
    {   borrowernumber => $patron->{borrowernumber},
47
        itemnumber     => $item_2->{itemnumber},
45
        itemnumber     => $item_2->{itemnumber},
48
        branchcode     => $library->{branchcode},
49
    }
46
    }
50
)->store;
47
)->store;
51
48
52
like( $new_checkout_1->issue_id, qr|^\d+$|, 'Adding a new checkout should have set the issue_id' );
49
like( $new_issue_1->issue_id, qr|^\d+$|, 'Adding a new issue should have set the issue_id' );
53
is( Koha::Checkouts->search->count, $nb_of_checkouts + 2, 'The 2 checkouts should have been added' );
50
is( Koha::Checkouts->search->count, $nb_of_issues + 2, 'The 2 issues should have been added' );
54
51
55
my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id );
52
my $retrieved_issue_1 = Koha::Checkouts->find( $new_issue_1->issue_id );
56
is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' );
53
is( $retrieved_issue_1->itemnumber, $new_issue_1->itemnumber, 'Find a issue by id should return the correct issue' );
57
54
58
$retrieved_checkout_1->delete;
55
$retrieved_issue_1->delete;
59
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' );
56
is( Koha::Checkouts->search->count, $nb_of_issues + 1, 'Delete should delete the issue' );
60
57
61
$schema->storage->txn_rollback;
58
$schema->storage->txn_rollback;
62
59
(-)a/t/db_dependent/Koha/Issues.t (-61 lines)
Lines 1-60 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2015 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 4;
23
24
use Koha::Issue;
25
use Koha::Issues;
26
use Koha::Database;
27
28
use t::lib::TestBuilder;
29
30
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
32
33
my $builder      = t::lib::TestBuilder->new;
34
my $patron       = $builder->build( { source => 'Borrower' } );
35
my $item_1       = $builder->build( { source => 'Item' } );
36
my $item_2       = $builder->build( { source => 'Item' } );
37
my $nb_of_issues = Koha::Issues->search->count;
38
my $new_issue_1  = Koha::Issue->new(
39
    {   borrowernumber => $patron->{borrowernumber},
40
        itemnumber     => $item_1->{itemnumber},
41
    }
42
)->store;
43
my $new_issue_2 = Koha::Issue->new(
44
    {   borrowernumber => $patron->{borrowernumber},
45
        itemnumber     => $item_2->{itemnumber},
46
    }
47
)->store;
48
49
like( $new_issue_1->issue_id, qr|^\d+$|, 'Adding a new issue should have set the issue_id' );
50
is( Koha::Issues->search->count, $nb_of_issues + 2, 'The 2 issues should have been added' );
51
52
my $retrieved_issue_1 = Koha::Issues->find( $new_issue_1->issue_id );
53
is( $retrieved_issue_1->itemnumber, $new_issue_1->itemnumber, 'Find a issue by id should return the correct issue' );
54
55
$retrieved_issue_1->delete;
56
is( Koha::Issues->search->count, $nb_of_issues + 1, 'Delete should delete the issue' );
57
58
$schema->storage->txn_rollback;
59
60
1;
61
- 

Return to bug 16870