3 # Copyright 2017 Koha Development team
5 # This file is part of Koha
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.
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.
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>.
22 use Test::More tests => 4;
24 use Koha::Acquisition::Funds;
27 use t::lib::TestBuilder;
29 my $schema = Koha::Database->new->schema;
30 $schema->storage->txn_begin;
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',
39 like( $new_fund->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' );
42 my $retrieved_fund_1 = Koha::Acquisition::Funds->find( $new_fund->budget_id );
43 is( $retrieved_fund_1->budget_name, $new_fund->budget_name, 'Find a fund by budget_id should return the correct fund' );
45 $retrieved_fund_1->delete;
46 is( Koha::Acquisition::Funds->search->count, $nb_of_funds, 'Delete should have deleted the fund' );
48 $schema->storage->txn_rollback;