|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Copyright 2023 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 => 1; |
| 23 |
|
| 24 |
use Koha::Illbackend; |
| 25 |
|
| 26 |
use t::lib::TestBuilder; |
| 27 |
use t::lib::Mocks; |
| 28 |
|
| 29 |
my $builder = t::lib::TestBuilder->new; |
| 30 |
my $schema = Koha::Database->new->schema; |
| 31 |
|
| 32 |
subtest 'existing_statuses() tests' => sub { |
| 33 |
|
| 34 |
plan tests => 2; |
| 35 |
|
| 36 |
$schema->storage->txn_begin; |
| 37 |
Koha::Illrequests->search->delete; |
| 38 |
|
| 39 |
my $alias = $builder->build_object( |
| 40 |
{ |
| 41 |
class => 'Koha::AuthorisedValues', |
| 42 |
value => { |
| 43 |
category => 'ILL_STATUS_ALIAS', |
| 44 |
authorised_value => 'BOB', |
| 45 |
lib => "Bob is the best status" |
| 46 |
} |
| 47 |
} |
| 48 |
); |
| 49 |
|
| 50 |
my $req = $builder->build_object( |
| 51 |
{ |
| 52 |
class => 'Koha::Illrequests', |
| 53 |
value => { |
| 54 |
status => 'REQ', |
| 55 |
status_alias => undef, |
| 56 |
biblio_id => undef, |
| 57 |
backend => 'FreeForm' |
| 58 |
} |
| 59 |
} |
| 60 |
); |
| 61 |
my $chk = $builder->build_object( |
| 62 |
{ |
| 63 |
class => 'Koha::Illrequests', |
| 64 |
value => { |
| 65 |
status => 'CHK', |
| 66 |
status_alias => undef, |
| 67 |
biblio_id => undef, |
| 68 |
backend => 'FreeForm' |
| 69 |
} |
| 70 |
} |
| 71 |
); |
| 72 |
my $bob = $builder->build_object( |
| 73 |
{ |
| 74 |
class => 'Koha::Illrequests', |
| 75 |
value => { |
| 76 |
status => 'REQ', |
| 77 |
status_alias => 'BOB', |
| 78 |
biblio_id => undef, |
| 79 |
backend => 'FreeForm' |
| 80 |
} |
| 81 |
} |
| 82 |
); |
| 83 |
my $req2 = $builder->build_object( |
| 84 |
{ |
| 85 |
class => 'Koha::Illrequests', |
| 86 |
value => { |
| 87 |
status => 'REQ', |
| 88 |
status_alias => undef, |
| 89 |
biblio_id => undef, |
| 90 |
backend => 'FreeForm' |
| 91 |
} |
| 92 |
} |
| 93 |
); |
| 94 |
|
| 95 |
my $backend_module = Koha::Illbackend->new; |
| 96 |
|
| 97 |
my $existing_statuses = $backend_module->existing_statuses('FreeForm'); |
| 98 |
|
| 99 |
is( @{$existing_statuses}, 3, "Return 3 unique existing statuses" ); |
| 100 |
|
| 101 |
# FIXME: Add tests to check content and order of return |
| 102 |
my $expected_statuses = [ |
| 103 |
{ code => 'CHK', str => 'Checked out' }, |
| 104 |
{ code => 'REQ', str => 'Requested' }, |
| 105 |
{ code => 'BOB', str => 'Bob is the best status' } |
| 106 |
]; |
| 107 |
|
| 108 |
is_deeply( $existing_statuses, $expected_statuses, 'Deep match on return' ); |
| 109 |
|
| 110 |
$schema->storage->txn_rollback; |
| 111 |
}; |