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

(-)a/t/db_dependent/api/v1/acquisitions_baskets.t (+63 lines)
Line 0 Link Here
1
#!/usr/bin/env perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 1;
21
use Test::Mojo;
22
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
26
use JSON qw(encode_json);
27
28
use Koha::Database;
29
30
my $schema  = Koha::Database->new->schema;
31
my $builder = t::lib::TestBuilder->new();
32
my $t       = Test::Mojo->new('Koha::REST::V1');
33
34
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
35
36
subtest 'list_managers() tests' => sub {
37
38
    plan tests => 3;
39
40
    $schema->storage->txn_begin;
41
42
    my $patron_with_permission =
43
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 2**11 } } )
44
      ;    ## 11 == acquisition
45
    my $patron_without_permission =
46
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } );
47
    my $superlibrarian =
48
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } );
49
    my $password = 'thePassword123';
50
    $superlibrarian->set_password( { password => $password, skip_validation => 1 } );
51
    my $userid = $superlibrarian->userid;
52
53
    my $api_filter = encode_json(
54
        {   'me.patron_id' =>
55
              [ $patron_with_permission->id, $patron_without_permission->id, $superlibrarian->id ]
56
        }
57
    );
58
59
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/baskets/managers?q=$api_filter")
60
      ->status_is(200)->json_is( [ $patron_with_permission->to_api, $superlibrarian->to_api ] );
61
62
    $schema->storage->txn_rollback;
63
};
(-)a/t/db_dependent/api/v1/acquisitions_funds.t (-3 / +35 lines)
Lines 17-27 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 13;
20
use Test::More tests => 14;
21
use Test::Mojo;
21
use Test::Mojo;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
24
25
use JSON qw(encode_json);
26
25
use C4::Budgets;
27
use C4::Budgets;
26
28
27
use Koha::Database;
29
use Koha::Database;
Lines 85-88 $t->get_ok("//$userid:$password@/api/v1/acquisitions/funds?name=" . $fund_name) Link Here
85
87
86
$schema->storage->txn_rollback;
88
$schema->storage->txn_rollback;
87
89
88
1;
90
subtest 'list_owners() and list_users() tests' => sub {
91
92
    plan tests => 6;
93
94
    $schema->storage->txn_begin;
95
96
    my $patron_with_permission =
97
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 2**11 } } )
98
      ;    ## 11 == acquisition
99
    my $patron_without_permission =
100
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 0 } } );
101
    my $superlibrarian =
102
      $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } );
103
    my $password = 'thePassword123';
104
    $superlibrarian->set_password( { password => $password, skip_validation => 1 } );
105
    my $userid = $superlibrarian->userid;
106
107
    # Restrict the query to a know list of patrons
108
    my $api_filter = encode_json(
109
        {   'me.patron_id' =>
110
              [ $patron_with_permission->id, $patron_without_permission->id, $superlibrarian->id ]
111
        }
112
    );
113
114
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/funds/owners?q=$api_filter")
115
      ->status_is(200)->json_is( [ $patron_with_permission->to_api, $superlibrarian->to_api ] );
116
117
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/funds/users?q=$api_filter")
118
      ->status_is(200)->json_is( [ $patron_with_permission->to_api, $superlibrarian->to_api ] );
119
120
    $schema->storage->txn_rollback;
121
};
89
- 

Return to bug 30055