3 # This file is part of Koha.
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
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.
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.
20 use Test::More tests => 13;
22 use t::lib::TestBuilder;
29 my $schema = Koha::Database->new->schema;
30 my $builder = t::lib::TestBuilder->new();
32 $schema->storage->txn_begin;
34 t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
36 my $t = Test::Mojo->new('Koha::REST::V1');
38 my $librarian = $builder->build_object({
39 class => 'Koha::Patrons',
40 value => { flags => 2052 }
42 my $password = 'thePassword123';
43 $librarian->set_password({ password => $password, skip_validation => 1 });
44 my $userid = $librarian->userid;
46 my $patron = $builder->build_object({
47 class => 'Koha::Patrons',
48 value => { flags => 0 }
50 my $unauth_password = 'thePassword123';
51 $patron->set_password({ password => $unauth_password, skip_validation => 1 });
52 my $unauth_userid = $patron->userid;
54 my $fund_name = 'Periodiques';
56 my $fund = $builder->build_object(
58 class => 'Koha::Acquisition::Funds',
60 budget_amount => '123.132000',
61 budget_name => $fund_name,
62 budget_notes => 'This is a note'
67 $t->get_ok('/api/v1/acquisitions/funds')
70 $t->get_ok('/api/v1/acquisitions/funds/?name=testFund')
73 $t->get_ok("//$unauth_userid:$unauth_password@/api/v1/acquisitions/funds")
76 $t->get_ok("//$unauth_userid:$unauth_password@/api/v1/acquisitions/funds?name=" . $fund_name)
79 $t->get_ok("//$userid:$password@/api/v1/acquisitions/funds")
82 $t->get_ok("//$userid:$password@/api/v1/acquisitions/funds?name=" . $fund_name)
84 ->json_like('/0/name' => qr/$fund_name/);
86 $schema->storage->txn_rollback;