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

(-)a/Koha/Acquisition/Budgets.pm (+2 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Koha::Database;
20
use Koha::Database;
21
21
22
use Koha::Acquisition::Budget;
23
22
use base qw(Koha::Objects);
24
use base qw(Koha::Objects);
23
25
24
=head1 NAME
26
=head1 NAME
(-)a/t/db_dependent/Koha/Acquisition/Budgets.t (+54 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2017 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::Acquisition::Budgets;
25
use Koha::Database;
26
use Koha::DateUtils qw( dt_from_string );
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 $nb_of_budgets= Koha::Acquisition::Budgets->search->count;
35
my $now = dt_from_string;
36
my $new_budget = Koha::Acquisition::Budget->new({
37
    budget_period_startdate => $now,
38
    budget_period_enddate => $now,
39
    budget_period_active => 1,
40
    budget_period_description => 'a new budget',
41
    budget_period_total => 1000,
42
})->store;
43
44
like( $new_budget->budget_period_id, qr|^\d+$|, 'Adding a new budget should have set the budget_period_id');
45
is( Koha::Acquisition::Budgets->search->count, $nb_of_budgets + 1, 'The budget should have been added' );
46
47
my $retrieved_budget = Koha::Acquisition::Budgets->find( $new_budget->budget_period_id);
48
is( $retrieved_budget->budget_period_description, $new_budget->budget_period_description, 'Find a budget by budget_period_id should return the correct budget' );
49
50
$retrieved_budget->delete;
51
is( Koha::Acquisition::Budgets->search->count, $nb_of_budgets, 'Delete should have deleted the budget' );
52
53
$schema->storage->txn_rollback;
54
(-)a/t/db_dependent/Koha/Acquisition/Funds.t (-1 / +49 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2017 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::Acquisition::Funds;
25
use Koha::Database;
26
27
use t::lib::TestBuilder;
28
29
my $schema = Koha::Database->new->schema;
30
$schema->storage->txn_begin;
31
32
my $builder = t::lib::TestBuilder->new;
33
my $nb_of_funds = Koha::Acquisition::Funds->search->count;
34
my $new_fund = Koha::Acquisition::Fund->new({
35
    budget_code => 'my_budget_code_for_test',
36
    budget_name => 'my_budget_name_for_test',
37
})->store;
38
39
like( $new_fund_1->budget_id, qr|^\d+$|, 'Adding a new fund should have set the budget_id');
40
is( Koha::Acquisition::Funds->search->count, $nb_of_funds + 1, 'The fund should have been added' );
41
42
my $retrieved_fund_1 = Koha::Acquisition::Funds->find( $new_fund_1->budget_id );
43
is( $retrieved_fund_1->fund_name, $new_fund_1->fund_name, 'Find a fund by budget_id should return the correct fund' );
44
45
$retrieved_fund_1->delete;
46
is( Koha::Acquisition::Funds->search->count, $nb_of_funds + 1, 'Delete should have deleted the fund' );
47
48
$schema->storage->txn_rollback;
49

Return to bug 19826