|
Line 0
Link Here
|
| 0 |
- |
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 <https://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use Test::NoWarnings; |
| 21 |
use Test::More tests => 2; |
| 22 |
use Test::Mojo; |
| 23 |
|
| 24 |
use t::lib::TestBuilder; |
| 25 |
use t::lib::Mocks; |
| 26 |
|
| 27 |
use Koha::Database; |
| 28 |
|
| 29 |
my $schema = Koha::Database->new->schema; |
| 30 |
my $builder = t::lib::TestBuilder->new; |
| 31 |
|
| 32 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
| 33 |
|
| 34 |
subtest 'count() tests' => sub { |
| 35 |
|
| 36 |
plan tests => 3; |
| 37 |
|
| 38 |
$schema->storage->txn_begin; |
| 39 |
|
| 40 |
my $librarian = $builder->build_object( |
| 41 |
{ |
| 42 |
class => 'Koha::Patrons', |
| 43 |
value => { flags => 2**28 } |
| 44 |
} |
| 45 |
); |
| 46 |
|
| 47 |
my $password = 'thePassword123'; |
| 48 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
| 49 |
my $userid = $librarian->userid; |
| 50 |
|
| 51 |
## Authorized user tests |
| 52 |
my $agreement = $builder->build_object( |
| 53 |
{ |
| 54 |
class => 'Koha::ERM::Agreements', |
| 55 |
} |
| 56 |
); |
| 57 |
|
| 58 |
my $license = $builder->build_object( |
| 59 |
{ |
| 60 |
class => 'Koha::ERM::Licenses', |
| 61 |
} |
| 62 |
); |
| 63 |
|
| 64 |
$t->get_ok("//$userid:$password@/api/v1/erm/counts")->status_is(200)->json_is( |
| 65 |
{ |
| 66 |
counts => { |
| 67 |
agreements_count => 1, documents_count => 0, eholdings_packages_count => 0, |
| 68 |
eholdings_titles_count => 0, licenses_count => 1, usage_data_providers_count => 0 |
| 69 |
} |
| 70 |
} |
| 71 |
); |
| 72 |
$schema->storage->txn_rollback; |
| 73 |
}; |