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

(-)a/C4/Circulation.pm (-3 / +3 lines)
Lines 45-51 use Koha::Biblioitems; Link Here
45
use Koha::DateUtils qw( dt_from_string );
45
use Koha::DateUtils qw( dt_from_string );
46
use Koha::Calendar;
46
use Koha::Calendar;
47
use Koha::Checkouts;
47
use Koha::Checkouts;
48
use Koha::Illrequests;
48
use Koha::ILL::Requests;
49
use Koha::Items;
49
use Koha::Items;
50
use Koha::Patrons;
50
use Koha::Patrons;
51
use Koha::Patron::Debarments qw( DelUniqueDebarment AddUniqueDebarment );
51
use Koha::Patron::Debarments qw( DelUniqueDebarment AddUniqueDebarment );
Lines 1612-1618 sub AddIssue { Link Here
1612
            # Check if we need to use an exact due date set by the ILL module
1612
            # Check if we need to use an exact due date set by the ILL module
1613
            if ( C4::Context->preference('ILLModule') ) {
1613
            if ( C4::Context->preference('ILLModule') ) {
1614
                # Check if there is an ILL connected with the biblio of the item we are issuing
1614
                # Check if there is an ILL connected with the biblio of the item we are issuing
1615
                my $ill_request = Koha::Illrequests->search({
1615
                my $ill_request = Koha::ILL::Requests->search({
1616
                    biblio_id => $item_object->biblionumber,
1616
                    biblio_id => $item_object->biblionumber,
1617
                    borrowernumber => $patron->borrowernumber,
1617
                    borrowernumber => $patron->borrowernumber,
1618
                    completed => undef,
1618
                    completed => undef,
Lines 2504-2510 sub AddReturn { Link Here
2504
    # Check if this item belongs to a biblio record that is attached to an
2504
    # Check if this item belongs to a biblio record that is attached to an
2505
    # ILL request, if it is we need to update the ILL request's status
2505
    # ILL request, if it is we need to update the ILL request's status
2506
    if ( $doreturn and C4::Context->preference('CirculateILL')) {
2506
    if ( $doreturn and C4::Context->preference('CirculateILL')) {
2507
        my $request = Koha::Illrequests->find(
2507
        my $request = Koha::ILL::Requests->find(
2508
            { biblio_id => $item->biblio->biblionumber }
2508
            { biblio_id => $item->biblio->biblionumber }
2509
        );
2509
        );
2510
        $request->status('RET') if $request;
2510
        $request->status('RET') if $request;
(-)a/C4/Letters.pm (-1 / +1 lines)
Lines 1859-1865 sub _get_tt_params { Link Here
1859
            fk       => 'verification_token',
1859
            fk       => 'verification_token',
1860
        },
1860
        },
1861
        illrequests => {
1861
        illrequests => {
1862
            module   => 'Koha::Illrequests',
1862
            module   => 'Koha::ILL::Requests',
1863
            singular => 'illrequest',
1863
            singular => 'illrequest',
1864
            plural   => 'illrequests',
1864
            plural   => 'illrequests',
1865
            pk       => 'illrequest_id'
1865
            pk       => 'illrequest_id'
(-)a/Koha/Biblio.pm (-3 / +3 lines)
Lines 41-47 use Koha::Bookings; Link Here
41
use Koha::Checkouts;
41
use Koha::Checkouts;
42
use Koha::CirculationRules;
42
use Koha::CirculationRules;
43
use Koha::Exceptions;
43
use Koha::Exceptions;
44
use Koha::Illrequests;
44
use Koha::ILL::Requests;
45
use Koha::Item::Transfer::Limits;
45
use Koha::Item::Transfer::Limits;
46
use Koha::Items;
46
use Koha::Items;
47
use Koha::Libraries;
47
use Koha::Libraries;
Lines 172-178 sub tickets { Link Here
172
172
173
    my $ill_requests = $biblio->ill_requests();
173
    my $ill_requests = $biblio->ill_requests();
174
174
175
Returns a Koha::Illrequests object
175
Returns a Koha::ILL::Requests object
176
176
177
=cut
177
=cut
178
178
Lines 180-186 sub ill_requests { Link Here
180
    my ( $self ) = @_;
180
    my ( $self ) = @_;
181
181
182
    my $ill_requests = $self->_result->ill_requests;
182
    my $ill_requests = $self->_result->ill_requests;
183
    return Koha::Illrequests->_new_from_dbic($ill_requests);
183
    return Koha::ILL::Requests->_new_from_dbic($ill_requests);
184
}
184
}
185
185
186
=head3 item_groups
186
=head3 item_groups
(-)a/Koha/ILL/Backend.pm (-2 / +2 lines)
Lines 55-61 sub existing_statuses { Link Here
55
    # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object.
55
    # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object.
56
    # Finally, to get around 'ONLY_FULL_GROUP_BY', we have to be explicit about which
56
    # Finally, to get around 'ONLY_FULL_GROUP_BY', we have to be explicit about which
57
    # 'request_id' we want to return, hense the 'MAX' call.
57
    # 'request_id' we want to return, hense the 'MAX' call.
58
    my $ill_requests = Koha::Illrequests->search(
58
    my $ill_requests = Koha::ILL::Requests->search(
59
        { backend => $backend_id },
59
        { backend => $backend_id },
60
        {
60
        {
61
            select   => [ 'status', \'MAX(illrequest_id)', 'backend' ],
61
            select   => [ 'status', \'MAX(illrequest_id)', 'backend' ],
Lines 78-84 sub existing_statuses { Link Here
78
    }
78
    }
79
79
80
    # Now do the same to get all status_aliases
80
    # Now do the same to get all status_aliases
81
    $ill_requests = Koha::Illrequests->search(
81
    $ill_requests = Koha::ILL::Requests->search(
82
        { backend => $backend_id },
82
        { backend => $backend_id },
83
        {
83
        {
84
            select   => [ 'status_alias', \'MAX(illrequest_id)', 'backend' ],
84
            select   => [ 'status_alias', \'MAX(illrequest_id)', 'backend' ],
(-)a/Koha/ILL/Batch.pm (-3 / +3 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use Koha::Database;
22
use Koha::Database;
23
23
24
use Koha::Illrequests;
24
use Koha::ILL::Requests;
25
use Koha::ILL::Request::Logger;
25
use Koha::ILL::Request::Logger;
26
use Koha::ILL::Batch::Statuses;
26
use Koha::ILL::Batch::Statuses;
27
use Koha::Libraries;
27
use Koha::Libraries;
Lines 81-94 sub library { Link Here
81
81
82
=head3 requests
82
=head3 requests
83
83
84
Return the I<Koha::Illrequests> for this batch
84
Return the I<Koha::ILL::Requests> for this batch
85
85
86
=cut
86
=cut
87
87
88
sub requests {
88
sub requests {
89
    my ($self) = @_;
89
    my ($self) = @_;
90
    my $requests = $self->_result->requests;
90
    my $requests = $self->_result->requests;
91
    return Koha::Illrequests->_new_from_dbic($requests);
91
    return Koha::ILL::Requests->_new_from_dbic($requests);
92
}
92
}
93
93
94
=head3 create_and_log
94
=head3 create_and_log
(-)a/Koha/Illrequest.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::Illrequest;
1
package Koha::ILL::Request;
2
2
3
# Copyright PTFS Europe 2016,2018
3
# Copyright PTFS Europe 2016,2018
4
#
4
#
Lines 48-58 use base qw(Koha::Object); Link Here
48
48
49
=head1 NAME
49
=head1 NAME
50
50
51
Koha::Illrequest - Koha Illrequest Object class
51
Koha::ILL::Request - Koha Illrequest Object class
52
52
53
=head1 (Re)Design
53
=head1 (Re)Design
54
54
55
An ILLRequest consists of two parts; the Illrequest Koha::Object, and a series
55
An ILLRequest consists of two parts; the ILL::Request Koha::Object, and a series
56
of related Illrequestattributes.
56
of related Illrequestattributes.
57
57
58
The former encapsulates the basic necessary information that any ILL requires
58
The former encapsulates the basic necessary information that any ILL requires
Lines 1233-1239 sub _limit_counter { Link Here
1233
    # Establish parameters of counts
1233
    # Establish parameters of counts
1234
    my $resultset;
1234
    my $resultset;
1235
    if ($method && $method eq 'annual') {
1235
    if ($method && $method eq 'annual') {
1236
        $resultset = Koha::Illrequests->search({
1236
        $resultset = Koha::ILL::Requests->search({
1237
            -and => [
1237
            -and => [
1238
                %{$target},
1238
                %{$target},
1239
                \"YEAR(placed) = YEAR(NOW())"
1239
                \"YEAR(placed) = YEAR(NOW())"
Lines 1243-1249 sub _limit_counter { Link Here
1243
        # XXX: This status list is ugly. There should be a method in config
1243
        # XXX: This status list is ugly. There should be a method in config
1244
        # to return these.
1244
        # to return these.
1245
        my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } };
1245
        my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } };
1246
        $resultset = Koha::Illrequests->search({ %{$target}, %{$where} });
1246
        $resultset = Koha::ILL::Requests->search( { %{$target}, %{$where} } );
1247
    }
1247
    }
1248
1248
1249
    # Fetch counts
1249
    # Fetch counts
(-)a/Koha/ILL/Request/Attribute.pm (-2 / +2 lines)
Lines 49-61 sub store { Link Here
49
49
50
=head3 request
50
=head3 request
51
51
52
Returns a Koha::Illrequest object representing the core request.
52
Returns a Koha::ILL::Request object representing the core request .
53
53
54
=cut
54
=cut
55
55
56
sub request {
56
sub request {
57
    my ($self) = @_;
57
    my ($self) = @_;
58
    return Koha::Illrequest->_new_from_dbic( $self->_result->illrequest );
58
    return Koha::ILL::Request->_new_from_dbic( $self->_result->illrequest );
59
}
59
}
60
60
61
=head2 Internal methods
61
=head2 Internal methods
(-)a/Koha/ILL/Request/SupplierUpdateProcessor.pm (-4 / +4 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
=head1 NAME
22
=head1 NAME
23
23
24
Koha::Illrequest::SupplierUpdateProcessor - Represents a SupplerUpdate processor
24
Koha::ILL::Request::SupplierUpdateProcessor - Represents a SupplerUpdate processor
25
25
26
=head1 SYNOPSIS
26
=head1 SYNOPSIS
27
27
Lines 40-51 a SupplierUpdate Link Here
40
40
41
=head3 new
41
=head3 new
42
42
43
    my $processor = Koha::Illrequest::SupplierUpdateProcessor->new(
43
    my $processor = Koha::ILL::Request::SupplierUpdateProcessor->new(
44
        $target_source_type,
44
        $target_source_type,
45
        $target_source_name
45
        $target_source_name
46
    );
46
    );
47
47
48
Create a new Koha::Illrequest::SupplierUpdateProcessor object.
48
Create a new Koha::ILL::Request::SupplierUpdateProcessor object .
49
49
50
=cut
50
=cut
51
51
Lines 64-70 sub new { Link Here
64
64
65
=head3 run
65
=head3 run
66
66
67
    Koha::Illrequest::SupplierUpdateProcessor->run();
67
    Koha::ILL::Request::SupplierUpdateProcessor->run();
68
68
69
Runs the processor
69
Runs the processor
70
70
(-)a/Koha/ILL/Request/Workflow/TypeDisclaimer.pm (-3 / +3 lines)
Lines 25-31 use base qw(Koha::ILL::Request::Workflow); Link Here
25
25
26
=head1 NAME
26
=head1 NAME
27
27
28
Koha::Illrequest::TypeDisclaimer - Koha ILL TypeDisclaimer
28
Koha::ILL::Request::TypeDisclaimer - Koha ILL TypeDisclaimer
29
29
30
=head1 SYNOPSIS
30
=head1 SYNOPSIS
31
31
Lines 43-49 and handle the template params accordingly Link Here
43
=head3 show_type_disclaimer
43
=head3 show_type_disclaimer
44
44
45
    my $show_type_disclaimer =
45
    my $show_type_disclaimer =
46
    Koha::Illrequest::TypeDisclaimer->show_type_disclaimer($params);
46
    Koha::ILL::Request::TypeDisclaimer->show_type_disclaimer($params);
47
47
48
Given $params, return true if type disclaimer should be shown
48
Given $params, return true if type disclaimer should be shown
49
49
Lines 80-86 sub show_type_disclaimer { Link Here
80
=head3 type_disclaimer_template_params
80
=head3 type_disclaimer_template_params
81
81
82
    my $type_disclaimer_template_params =
82
    my $type_disclaimer_template_params =
83
    Koha::Illrequest::TypeDisclaimer->type_disclaimer_template_params(
83
    Koha::ILL::Request::TypeDisclaimer->type_disclaimer_template_params(
84
        $params);
84
        $params);
85
85
86
Given $params, return true if type disclaimer should be rendered
86
Given $params, return true if type disclaimer should be rendered
(-)a/Koha/Illrequests.pm (-6 / +6 lines)
Lines 1-4 Link Here
1
package Koha::Illrequests;
1
package Koha::ILL::Requests;
2
2
3
# Copyright PTFS Europe 2016
3
# Copyright PTFS Europe 2016
4
#
4
#
Lines 20-33 package Koha::Illrequests; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::Illrequest;
23
use Koha::ILL::Request;
24
use Koha::ILL::Request::Config;
24
use Koha::ILL::Request::Config;
25
25
26
use base qw(Koha::Objects);
26
use base qw(Koha::Objects);
27
27
28
=head1 NAME
28
=head1 NAME
29
29
30
Koha::Illrequests - Koha Illrequests Object class
30
Koha::ILL::Requests - Koha Illrequests Object class
31
31
32
=head1 API
32
=head1 API
33
33
Lines 37-43 Koha::Illrequests - Koha Illrequests Object class Link Here
37
37
38
=head3 new
38
=head3 new
39
39
40
    my $illRequests = Koha::Illrequests->new();
40
    my $illRequests = Koha::ILL::Requests->new();
41
41
42
Create an ILLREQUESTS object, a singleton through which we can interact with
42
Create an ILLREQUESTS object, a singleton through which we can interact with
43
ILLREQUEST objects stored in the database or search for ILL candidates at API
43
ILLREQUEST objects stored in the database or search for ILL candidates at API
Lines 60-66 sub new { Link Here
60
60
61
    my $visible_requests = $requests->filter_by_visible;
61
    my $visible_requests = $requests->filter_by_visible;
62
62
63
Returns a I<Koha::Illrequests> resultset, filtered by statuses that are not listed
63
Returns a I<Koha::ILL::Requests> resultset, filtered by statuses that are not listed
64
as hidden in the I<ILLHiddenRequestStatuses> system preference.
64
as hidden in the I<ILLHiddenRequestStatuses> system preference.
65
65
66
=cut
66
=cut
Lines 121-127 sub _type { Link Here
121
=cut
121
=cut
122
122
123
sub object_class {
123
sub object_class {
124
    return 'Koha::Illrequest';
124
    return 'Koha::ILL::Request';
125
}
125
}
126
126
127
=head1 AUTHOR
127
=head1 AUTHOR
(-)a/Koha/REST/V1/ILL/Backends.pm (-3 / +3 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use Koha::ILL::Request::Config;
22
use Koha::ILL::Request::Config;
23
use Koha::Illrequests;
23
use Koha::ILL::Requests;
24
use Koha::ILL::Backend;
24
use Koha::ILL::Backend;
25
25
26
=head1 NAME
26
=head1 NAME
Lines 43-49 sub list { Link Here
43
43
44
    my @data;
44
    my @data;
45
    foreach my $b (@$backends) {
45
    foreach my $b (@$backends) {
46
        my $backend = Koha::Illrequest->new->load_backend($b);
46
        my $backend = Koha::ILL::Request->new->load_backend($b);
47
        push @data,
47
        push @data,
48
          {
48
          {
49
            ill_backend_id => $b,
49
            ill_backend_id => $b,
Lines 69-75 sub get { Link Here
69
        #FIXME: Should we move load_backend into Koha::ILL::Backend...
69
        #FIXME: Should we move load_backend into Koha::ILL::Backend...
70
        #       or maybe make Koha::Ill::Backend a base class for all
70
        #       or maybe make Koha::Ill::Backend a base class for all
71
        #       backends?
71
        #       backends?
72
        my $backend = Koha::Illrequest->new->load_backend($backend_id);
72
        my $backend = Koha::ILL::Request->new->load_backend($backend_id);
73
73
74
        my $backend_module = Koha::ILL::Backend->new;
74
        my $backend_module = Koha::ILL::Backend->new;
75
75
(-)a/Koha/REST/V1/ILL/Batches.pm (-1 / +1 lines)
Lines 21-27 use Mojo::Base 'Mojolicious::Controller'; Link Here
21
21
22
use Koha::ILL::Batches;
22
use Koha::ILL::Batches;
23
use Koha::ILL::Batch::Statuses;
23
use Koha::ILL::Batch::Statuses;
24
use Koha::Illrequests;
24
use Koha::ILL::Requests;
25
25
26
use Try::Tiny qw( catch try );
26
use Try::Tiny qw( catch try );
27
27
(-)a/Koha/REST/V1/Illrequests.pm (-6 / +6 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use C4::Context;
22
use C4::Context;
23
use Koha::Illrequests;
23
use Koha::ILL::Requests;
24
use Koha::ILL::Request::Attributes;
24
use Koha::ILL::Request::Attributes;
25
use Koha::Libraries;
25
use Koha::Libraries;
26
use Koha::Patrons;
26
use Koha::Patrons;
Lines 38-44 Koha::REST::V1::Illrequests Link Here
38
38
39
=head3 list
39
=head3 list
40
40
41
Controller function that handles listing Koha::Illrequest objects
41
Controller function that handles listing Koha::ILL::Request objects
42
42
43
=cut
43
=cut
44
44
Lines 47-53 sub list { Link Here
47
47
48
    return try {
48
    return try {
49
49
50
        my $reqs = $c->objects->search(Koha::Illrequests->new->filter_by_visible);
50
        my $reqs = $c->objects->search(Koha::ILL::Requests->new->filter_by_visible);
51
51
52
        return $c->render(
52
        return $c->render(
53
            status  => 200,
53
            status  => 200,
Lines 77-83 sub add { Link Here
77
                $body->{borrowernumber} = delete $body->{patron_id};
77
                $body->{borrowernumber} = delete $body->{patron_id};
78
                $body->{branchcode} = delete $body->{library_id};
78
                $body->{branchcode} = delete $body->{library_id};
79
79
80
                my $request = Koha::Illrequest->new->load_backend( $body->{backend} );
80
                my $request = Koha::ILL::Request->new->load_backend( $body->{backend} );
81
81
82
                my $create_api = $request->_backend->capabilities('create_api');
82
                my $create_api = $request->_backend->capabilities('create_api');
83
83
Lines 93-99 sub add { Link Here
93
                my $create_result = &{$create_api}($body, $request);
93
                my $create_result = &{$create_api}($body, $request);
94
                my $new_id = $create_result->illrequest_id;
94
                my $new_id = $create_result->illrequest_id;
95
95
96
                my $new_req = Koha::Illrequests->find($new_id);
96
                my $new_req = Koha::ILL::Requests->find($new_id);
97
97
98
                $c->res->headers->location($c->req->url->to_string . '/' . $new_req->illrequest_id);
98
                $c->res->headers->location($c->req->url->to_string . '/' . $new_req->illrequest_id);
99
                return $c->render(
99
                return $c->render(
Lines 105-111 sub add { Link Here
105
    }
105
    }
106
    catch {
106
    catch {
107
107
108
        my $to_api_mapping = Koha::Illrequest->new->to_api_mapping;
108
        my $to_api_mapping = Koha::ILL::Request->new->to_api_mapping;
109
109
110
        if ( blessed $_ ) {
110
        if ( blessed $_ ) {
111
            if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
111
            if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
(-)a/Koha/Schema/Result/Illrequest.pm (+8 lines)
Lines 439-442 __PACKAGE__->belongs_to( Link Here
439
  },
439
  },
440
);
440
);
441
441
442
sub koha_object_class {
443
    'Koha::ILL::Request';
444
}
445
446
sub koha_objects_class {
447
    'Koha::ILL::Requests';
448
}
449
442
1;
450
1;
(-)a/catalogue/detail.pl (-2 / +2 lines)
Lines 50-56 use Koha::Biblio::ItemGroup::Items; Link Here
50
use Koha::Biblio::ItemGroups;
50
use Koha::Biblio::ItemGroups;
51
use Koha::CoverImages;
51
use Koha::CoverImages;
52
use Koha::DateUtils;
52
use Koha::DateUtils;
53
use Koha::Illrequests;
53
use Koha::ILL::Requests;
54
use Koha::Items;
54
use Koha::Items;
55
use Koha::ItemTypes;
55
use Koha::ItemTypes;
56
use Koha::Patrons;
56
use Koha::Patrons;
Lines 595-601 $template->param( holdcount => $holds->count ); Link Here
595
# Check if there are any ILL requests connected to the biblio
595
# Check if there are any ILL requests connected to the biblio
596
my $illrequests =
596
my $illrequests =
597
    C4::Context->preference('ILLModule')
597
    C4::Context->preference('ILLModule')
598
  ? Koha::Illrequests->search( { biblio_id => $biblionumber } )
598
  ? Koha::ILL::Requests->search( { biblio_id => $biblionumber } )
599
  : [];
599
  : [];
600
$template->param( illrequests => $illrequests );
600
$template->param( illrequests => $illrequests );
601
601
(-)a/ill/ill-requests.pl (-19 / +19 lines)
Lines 26-33 use C4::Output qw( output_and_exit output_html_with_http_headers ); Link Here
26
use Koha::Notice::Templates;
26
use Koha::Notice::Templates;
27
use Koha::AuthorisedValues;
27
use Koha::AuthorisedValues;
28
use Koha::ILL::Comment;
28
use Koha::ILL::Comment;
29
use Koha::Illrequests;
29
use Koha::ILL::Requests;
30
use Koha::Illrequest;
30
use Koha::ILL::Request;
31
use Koha::ILL::Batches;
31
use Koha::ILL::Batches;
32
use Koha::ILL::Request::Workflow::Availability;
32
use Koha::ILL::Request::Workflow::Availability;
33
use Koha::ILL::Request::Workflow::TypeDisclaimer;
33
use Koha::ILL::Request::Workflow::TypeDisclaimer;
Lines 39-45 use URI::Escape qw( uri_escape_utf8 ); Link Here
39
use JSON qw( encode_json );
39
use JSON qw( encode_json );
40
40
41
our $cgi = CGI->new;
41
our $cgi = CGI->new;
42
my $illRequests = Koha::Illrequests->new;
42
my $illRequests = Koha::ILL::Requests->new;
43
43
44
# Grab all passed data
44
# Grab all passed data
45
# 'our' since Plack changes the scoping
45
# 'our' since Plack changes the scoping
Lines 52-58 unless ( C4::Context->preference('ILLModule') ) { Link Here
52
    exit;
52
    exit;
53
}
53
}
54
54
55
my $op = Koha::Illrequest->get_op_param_deprecation( 'intranet', $params );
55
my $op = Koha::ILL::Request->get_op_param_deprecation( 'intranet', $params );
56
56
57
my ( $template, $patronnumber, $cookie ) = get_template_and_user( {
57
my ( $template, $patronnumber, $cookie ) = get_template_and_user( {
58
    template_name => 'ill/ill-requests.tt',
58
    template_name => 'ill/ill-requests.tt',
Lines 91-97 if ( $backends_available ) { Link Here
91
91
92
    if ( $op eq 'illview' ) {
92
    if ( $op eq 'illview' ) {
93
        # View the details of an ILL
93
        # View the details of an ILL
94
        my $request = Koha::Illrequests->find($params->{illrequest_id});
94
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
95
95
96
        # Get the details for notices that can be sent from here
96
        # Get the details for notices that can be sent from here
97
        my $notices = Koha::Notice::Templates->search(
97
        my $notices = Koha::Notice::Templates->search(
Lines 124-130 if ( $backends_available ) { Link Here
124
124
125
    } elsif ( $op eq 'cud-create' ) {
125
    } elsif ( $op eq 'cud-create' ) {
126
        # Load the ILL backend
126
        # Load the ILL backend
127
        my $request = Koha::Illrequest->new->load_backend( $params->{backend} );
127
        my $request = Koha::ILL::Request->new->load_backend( $params->{backend} );
128
128
129
        # Before request creation operations - Preparation
129
        # Before request creation operations - Preparation
130
        my $availability =
130
        my $availability =
Lines 161-167 if ( $backends_available ) { Link Here
161
        }
161
        }
162
    } elsif ( $op eq 'migrate' ) {
162
    } elsif ( $op eq 'migrate' ) {
163
        # We're in the process of migrating a request
163
        # We're in the process of migrating a request
164
        my $request = Koha::Illrequests->find($params->{illrequest_id});
164
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
165
        my $backend_result;
165
        my $backend_result;
166
        if ( $params->{backend} ) {
166
        if ( $params->{backend} ) {
167
            $backend_result = $request->backend_migrate($params);
167
            $backend_result = $request->backend_migrate($params);
Lines 192-198 if ( $backends_available ) { Link Here
192
    } elsif ( $op eq 'confirm' ) {
192
    } elsif ( $op eq 'confirm' ) {
193
        # Backend 'confirm' method
193
        # Backend 'confirm' method
194
        # confirm requires a specific request, so first, find it.
194
        # confirm requires a specific request, so first, find it.
195
        my $request = Koha::Illrequests->find($params->{illrequest_id});
195
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
196
        my $backend_result = $request->backend_confirm($params);
196
        my $backend_result = $request->backend_confirm($params);
197
        $template->param(
197
        $template->param(
198
            whole   => $backend_result,
198
            whole   => $backend_result,
Lines 205-211 if ( $backends_available ) { Link Here
205
    } elsif ( $op eq 'cud-cancel' ) {
205
    } elsif ( $op eq 'cud-cancel' ) {
206
        # Backend 'cancel' method
206
        # Backend 'cancel' method
207
        # cancel requires a specific request, so first, find it.
207
        # cancel requires a specific request, so first, find it.
208
        my $request = Koha::Illrequests->find($params->{illrequest_id});
208
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
209
        my $backend_result = $request->backend_cancel($params);
209
        my $backend_result = $request->backend_cancel($params);
210
        $template->param(
210
        $template->param(
211
            whole   => $backend_result,
211
            whole   => $backend_result,
Lines 220-226 if ( $backends_available ) { Link Here
220
        # (not the Illrequestattributes)
220
        # (not the Illrequestattributes)
221
        # We simulate the API for backend requests for uniformity.
221
        # We simulate the API for backend requests for uniformity.
222
        # So, init:
222
        # So, init:
223
        my $request = Koha::Illrequests->find($params->{illrequest_id});
223
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
224
        my $batches = Koha::ILL::Batches->search(undef, {
224
        my $batches = Koha::ILL::Batches->search(undef, {
225
            order_by => { -asc => 'name' }
225
            order_by => { -asc => 'name' }
226
        });
226
        });
Lines 273-279 if ( $backends_available ) { Link Here
273
        redirect_to_list();
273
        redirect_to_list();
274
274
275
    } elsif ( $op eq 'delete_confirm') {
275
    } elsif ( $op eq 'delete_confirm') {
276
        my $request = Koha::Illrequests->find($params->{illrequest_id});
276
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
277
277
278
        $template->param(
278
        $template->param(
279
            request => $request
279
            request => $request
Lines 285-291 if ( $backends_available ) { Link Here
285
        # to the confirmation view
285
        # to the confirmation view
286
        if ($params->{confirmed}) {
286
        if ($params->{confirmed}) {
287
            # We simply delete the request...
287
            # We simply delete the request...
288
            Koha::Illrequests->find( $params->{illrequest_id} )->delete;
288
            Koha::ILL::Requests->find( $params->{illrequest_id} )->delete;
289
            # ... then return to list view.
289
            # ... then return to list view.
290
            redirect_to_list();
290
            redirect_to_list();
291
        } else {
291
        } else {
Lines 297-303 if ( $backends_available ) { Link Here
297
        }
297
        }
298
298
299
    } elsif ( $op eq 'mark_completed' ) {
299
    } elsif ( $op eq 'mark_completed' ) {
300
        my $request = Koha::Illrequests->find($params->{illrequest_id});
300
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
301
        my $backend_result = $request->mark_completed($params);
301
        my $backend_result = $request->mark_completed($params);
302
        $template->param(
302
        $template->param(
303
            whole => $backend_result,
303
            whole => $backend_result,
Lines 312-318 if ( $backends_available ) { Link Here
312
        my $backend_result;
312
        my $backend_result;
313
        my $request;
313
        my $request;
314
        try {
314
        try {
315
            $request = Koha::Illrequests->find($params->{illrequest_id});
315
            $request = Koha::ILL::Requests->find($params->{illrequest_id});
316
            $params->{current_branchcode} = C4::Context->mybranch;
316
            $params->{current_branchcode} = C4::Context->mybranch;
317
            $backend_result = $request->generic_confirm($params);
317
            $backend_result = $request->generic_confirm($params);
318
318
Lines 369-375 if ( $backends_available ) { Link Here
369
        # handle special commit rules & update type
369
        # handle special commit rules & update type
370
        handle_commit_maybe($backend_result, $request);
370
        handle_commit_maybe($backend_result, $request);
371
    } elsif ( $op eq 'check_out') {
371
    } elsif ( $op eq 'check_out') {
372
        my $request = Koha::Illrequests->find($params->{illrequest_id});
372
        my $request = Koha::ILL::Requests->find($params->{illrequest_id});
373
        my $backend_result = $request->check_out($params);
373
        my $backend_result = $request->check_out($params);
374
        $template->param(
374
        $template->param(
375
            params  => $params,
375
            params  => $params,
Lines 409-415 if ( $backends_available ) { Link Here
409
            }
409
            }
410
        }
410
        }
411
411
412
        $template->param( table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ) );
412
        $template->param( table_actions => encode_json( Koha::ILL::Request->get_staff_table_actions ) );
413
    } elsif ( $op eq "save_comment" ) {
413
    } elsif ( $op eq "save_comment" ) {
414
        my $comment = Koha::ILL::Comment->new({
414
        my $comment = Koha::ILL::Comment->new({
415
            illrequest_id  => scalar $params->{illrequest_id},
415
            illrequest_id  => scalar $params->{illrequest_id},
Lines 425-431 if ( $backends_available ) { Link Here
425
425
426
    } elsif ( $op eq "send_notice" ) {
426
    } elsif ( $op eq "send_notice" ) {
427
        my $illrequest_id = $params->{illrequest_id};
427
        my $illrequest_id = $params->{illrequest_id};
428
        my $request = Koha::Illrequests->find($illrequest_id);
428
        my $request = Koha::ILL::Requests->find($illrequest_id);
429
        my $ret = $request->send_patron_notice($params->{notice_code});
429
        my $ret = $request->send_patron_notice($params->{notice_code});
430
        my $append = '';
430
        my $append = '';
431
        if ($ret->{result} && scalar @{$ret->{result}->{success}} > 0) {
431
        if ($ret->{result} && scalar @{$ret->{result}->{success}} > 0) {
Lines 446-452 if ( $backends_available ) { Link Here
446
        # Do not remove, it prevents us falling through to the 'else'
446
        # Do not remove, it prevents us falling through to the 'else'
447
    } else {
447
    } else {
448
        $op =~ s/^cud-//;
448
        $op =~ s/^cud-//;
449
        my $request = Koha::Illrequests->find($params->{illrequest_id});
449
        my $request = Koha::ILL::Requests->find( $params->{illrequest_id} );
450
        my $backend_result = $request->custom_capability($op, $params);
450
        my $backend_result = $request->custom_capability($op, $params);
451
        $template->param(
451
        $template->param(
452
            whole => $backend_result,
452
            whole => $backend_result,
Lines 522-528 sub have_batch_backends { Link Here
522
# FIXME: This should be moved to Koha::Illbackend
522
# FIXME: This should be moved to Koha::Illbackend
523
sub can_batch {
523
sub can_batch {
524
    my ( $backend ) = @_;
524
    my ( $backend ) = @_;
525
    my $request = Koha::Illrequest->new->load_backend( $backend );
525
    my $request = Koha::ILL::Request->new->load_backend( $backend );
526
    return $request->_backend_capability( 'provides_batch_requests' );
526
    return $request->_backend_capability( 'provides_batch_requests' );
527
}
527
}
528
528
(-)a/misc/process_ill_updates.pl (-2 / +2 lines)
Lines 22-28 use Getopt::Long qw( GetOptions ); Link Here
22
use POSIX;
22
use POSIX;
23
23
24
use Koha::Script;
24
use Koha::Script;
25
use Koha::Illrequests;
25
use Koha::ILL::Requests;
26
26
27
# Command line option values
27
# Command line option values
28
my $get_help = 0;
28
my $get_help = 0;
Lines 96-102 if (scalar @status_alias_arr > 0) { Link Here
96
debug_msg("DBIC WHERE:");
96
debug_msg("DBIC WHERE:");
97
debug_msg($where);
97
debug_msg($where);
98
98
99
my $requests = Koha::Illrequests->search($where);
99
my $requests = Koha::ILL::Requests->search($where);
100
100
101
debug_msg("Processing " . $requests->count . " requests");
101
debug_msg("Processing " . $requests->count . " requests");
102
102
(-)a/opac/opac-illrequests.pl (-7 / +7 lines)
Lines 28-35 use C4::Output qw( output_html_with_http_headers ); Link Here
28
use POSIX qw( strftime );
28
use POSIX qw( strftime );
29
29
30
use Koha::ILL::Request::Config;
30
use Koha::ILL::Request::Config;
31
use Koha::Illrequests;
31
use Koha::ILL::Requests;
32
use Koha::Illrequest;
32
use Koha::ILL::Request;
33
use Koha::Libraries;
33
use Koha::Libraries;
34
use Koha::Patrons;
34
use Koha::Patrons;
35
use Koha::ILL::Request::Workflow::Availability;
35
use Koha::ILL::Request::Workflow::Availability;
Lines 61-71 my $backends_available = ( scalar @{$backends} > 0 ); Link Here
61
$template->param( backends_available => $backends_available );
61
$template->param( backends_available => $backends_available );
62
my $patron = Koha::Patrons->find($loggedinuser);
62
my $patron = Koha::Patrons->find($loggedinuser);
63
63
64
my $op = Koha::Illrequest->get_op_param_deprecation( 'opac', $params );
64
my $op = Koha::ILL::Request->get_op_param_deprecation( 'opac', $params );
65
65
66
my ( $illrequest_id, $request );
66
my ( $illrequest_id, $request );
67
if ( $illrequest_id = $params->{illrequest_id} ) {
67
if ( $illrequest_id = $params->{illrequest_id} ) {
68
    $request = Koha::Illrequests->find($illrequest_id);
68
    $request = Koha::ILL::Requests->find($illrequest_id);
69
    # Make sure the request belongs to the logged in user
69
    # Make sure the request belongs to the logged in user
70
    if( !$request || $request->borrowernumber != $loggedinuser ) {
70
    if( !$request || $request->borrowernumber != $loggedinuser ) {
71
        print $query->redirect("/cgi-bin/koha/errors/404.pl");
71
        print $query->redirect("/cgi-bin/koha/errors/404.pl");
Lines 80-86 if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$pat Link Here
80
80
81
if ( $op eq 'list' ) {
81
if ( $op eq 'list' ) {
82
82
83
    my $requests = Koha::Illrequests->search(
83
    my $requests = Koha::ILL::Requests->search(
84
        { borrowernumber => $loggedinuser }
84
        { borrowernumber => $loggedinuser }
85
    );
85
    );
86
    $template->param(
86
    $template->param(
Lines 111-122 if ( $op eq 'list' ) { Link Here
111
    exit;
111
    exit;
112
} elsif ( $op eq 'cud-create' ) {
112
} elsif ( $op eq 'cud-create' ) {
113
    if (!$params->{backend}) {
113
    if (!$params->{backend}) {
114
        my $req = Koha::Illrequest->new;
114
        my $req = Koha::ILL::Request->new;
115
        $template->param(
115
        $template->param(
116
            backends    => $req->available_backends
116
            backends    => $req->available_backends
117
        );
117
        );
118
    } else {
118
    } else {
119
        my $request = Koha::Illrequest->new
119
        my $request = Koha::ILL::Request->new
120
            ->load_backend($params->{backend});
120
            ->load_backend($params->{backend});
121
121
122
        # Before request creation operations - Preparation
122
        # Before request creation operations - Preparation
(-)a/t/db_dependent/Biblio.t (-2 / +2 lines)
Lines 718-725 subtest 'DelBiblio' => sub { Link Here
718
        { class => 'Koha::Acquisition::Orders', value => $orderinfo } );
718
        { class => 'Koha::Acquisition::Orders', value => $orderinfo } );
719
719
720
    # Add some ILL requests
720
    # Add some ILL requests
721
    my $ill_req_1 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } });
721
    my $ill_req_1 = $builder->build_object({ class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } });
722
    my $ill_req_2 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } });
722
    my $ill_req_2 = $builder->build_object({ class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } });
723
723
724
    C4::Biblio::DelBiblio($biblio->biblionumber); # Or $biblio->delete
724
    C4::Biblio::DelBiblio($biblio->biblionumber); # Or $biblio->delete
725
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
725
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
(-)a/t/db_dependent/Circulation.t (-2 / +2 lines)
Lines 2344-2350 subtest 'AddIssue & illrequests.due_date' => sub { Link Here
2344
2344
2345
    my $custom_date_due = '9999-12-18 12:34:56';
2345
    my $custom_date_due = '9999-12-18 12:34:56';
2346
    my $expected_date_due = '9999-12-18 23:59:00';
2346
    my $expected_date_due = '9999-12-18 23:59:00';
2347
    my $illrequest = Koha::Illrequest->new({
2347
    my $illrequest = Koha::ILL::Request->new({
2348
        borrowernumber => $patron->borrowernumber,
2348
        borrowernumber => $patron->borrowernumber,
2349
        biblio_id => $item->biblionumber,
2349
        biblio_id => $item->biblionumber,
2350
        branchcode => $library->{'branchcode'},
2350
        branchcode => $library->{'branchcode'},
Lines 2358-2364 subtest 'AddIssue & illrequests.due_date' => sub { Link Here
2358
    $item = $builder->build_sample_item();
2358
    $item = $builder->build_sample_item();
2359
    $custom_date_due = '9999-12-19';
2359
    $custom_date_due = '9999-12-19';
2360
    $expected_date_due = '9999-12-19 23:59:00';
2360
    $expected_date_due = '9999-12-19 23:59:00';
2361
    $illrequest = Koha::Illrequest->new({
2361
    $illrequest = Koha::ILL::Request->new({
2362
        borrowernumber => $patron->borrowernumber,
2362
        borrowernumber => $patron->borrowernumber,
2363
        biblio_id => $item->biblionumber,
2363
        biblio_id => $item->biblionumber,
2364
        branchcode => $library->{'branchcode'},
2364
        branchcode => $library->{'branchcode'},
(-)a/t/db_dependent/Illrequest/Availability.t (-3 / +3 lines)
Lines 75-82 $backend->mock( Link Here
75
);
75
);
76
$backend->mock( 'status_graph', sub { }, );
76
$backend->mock( 'status_graph', sub { }, );
77
77
78
# Mock Koha::Illrequest::load_backend (to load Mocked Backend)
78
# Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
79
my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
79
my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
80
$illreqmodule->mock( 'load_backend',
80
$illreqmodule->mock( 'load_backend',
81
    sub { my $self = shift; $self->{_my_backend} = $backend; return $self } );
81
    sub { my $self = shift; $self->{_my_backend} = $backend; return $self } );
82
82
Lines 90-96 $availability_module->mock( 'get_services', [ { name => 'service' } ] ); Link Here
90
90
91
my $req_1 = $builder->build_object(
91
my $req_1 = $builder->build_object(
92
    {
92
    {
93
        class => 'Koha::Illrequests',
93
        class => 'Koha::ILL::Requests',
94
        value => {}
94
        value => {}
95
    }
95
    }
96
);
96
);
(-)a/t/db_dependent/Illrequest/SupplierUpdate.t (-1 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use Test::MockObject;
20
use Test::MockObject;
21
21
22
use Koha::Illrequest;
22
use Koha::ILL::Request;
23
use Koha::ILL::Request::SupplierUpdate;
23
use Koha::ILL::Request::SupplierUpdate;
24
24
25
use Test::More tests => 4;
25
use Test::More tests => 4;
(-)a/t/db_dependent/Illrequest/SupplierUpdateProcessor.t (-4 / +4 lines)
Lines 17-36 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Illrequest::SupplierUpdateProcessor;
20
use Koha::ILL::Request::SupplierUpdateProcessor;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 3;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
my $processor = Koha::Illrequest::SupplierUpdateProcessor->new(
25
my $processor = Koha::ILL::Request::SupplierUpdateProcessor->new(
26
    'test_type',
26
    'test_type',
27
    'test_name',
27
    'test_name',
28
    'Test processor name'
28
    'Test processor name'
29
);
29
);
30
30
31
use_ok('Koha::Illrequest::SupplierUpdateProcessor');
31
use_ok('Koha::ILL::Request::SupplierUpdateProcessor');
32
32
33
isa_ok( $processor, 'Koha::Illrequest::SupplierUpdateProcessor' );
33
isa_ok( $processor, 'Koha::ILL::Request::SupplierUpdateProcessor' );
34
34
35
warning_like {
35
warning_like {
36
    $processor->run()
36
    $processor->run()
(-)a/t/db_dependent/Illrequest/TypeDisclaimer.t (-3 / +3 lines)
Lines 75-82 $backend->mock( Link Here
75
);
75
);
76
$backend->mock( 'status_graph', sub { }, );
76
$backend->mock( 'status_graph', sub { }, );
77
77
78
# Mock Koha::Illrequest::load_backend (to load Mocked Backend)
78
# Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
79
my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
79
my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
80
$illreqmodule->mock( 'load_backend',
80
$illreqmodule->mock( 'load_backend',
81
    sub { my $self = shift; $self->{_my_backend} = $backend; return $self } );
81
    sub { my $self = shift; $self->{_my_backend} = $backend; return $self } );
82
82
Lines 96-102 article: Link Here
96
96
97
my $req_1 = $builder->build_object(
97
my $req_1 = $builder->build_object(
98
    {
98
    {
99
        class => 'Koha::Illrequests',
99
        class => 'Koha::ILL::Requests',
100
        value => {}
100
        value => {}
101
    }
101
    }
102
);
102
);
(-)a/t/db_dependent/Koha/Biblio.t (-2 / +2 lines)
Lines 1127-1139 subtest 'ill_requests() tests' => sub { Link Here
1127
    my $biblio = $builder->build_sample_biblio;
1127
    my $biblio = $builder->build_sample_biblio;
1128
1128
1129
    my $rs = $biblio->ill_requests;
1129
    my $rs = $biblio->ill_requests;
1130
    is( ref($rs), 'Koha::Illrequests' );
1130
    is( ref($rs), 'Koha::ILL::Requests' );
1131
    is( $rs->count, 0, 'No linked requests' );
1131
    is( $rs->count, 0, 'No linked requests' );
1132
1132
1133
    foreach ( 1..10 ) {
1133
    foreach ( 1..10 ) {
1134
        $builder->build_object(
1134
        $builder->build_object(
1135
            {
1135
            {
1136
                class => 'Koha::Illrequests',
1136
                class => 'Koha::ILL::Requests',
1137
                value => { biblio_id => $biblio->id }
1137
                value => { biblio_id => $biblio->id }
1138
            }
1138
            }
1139
        );
1139
        );
(-)a/t/db_dependent/Koha/ILL/Backend.t (-8 / +8 lines)
Lines 34-40 subtest 'existing_statuses() tests' => sub { Link Here
34
    plan tests => 2;
34
    plan tests => 2;
35
35
36
    $schema->storage->txn_begin;
36
    $schema->storage->txn_begin;
37
    Koha::Illrequests->search->delete;
37
    Koha::ILL::Requests->search->delete;
38
38
39
    # Mock external ILLBackend (as object)
39
    # Mock external ILLBackend (as object)
40
    my $backend = Test::MockObject->new;
40
    my $backend = Test::MockObject->new;
Lines 58-65 subtest 'existing_statuses() tests' => sub { Link Here
58
        },
58
        },
59
    );
59
    );
60
60
61
    # Mock Koha::Illrequest::load_backend (to load Mocked Backend)
61
    # Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
62
    my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
62
    my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
63
    $illreqmodule->mock(
63
    $illreqmodule->mock(
64
        'load_backend',
64
        'load_backend',
65
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
65
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
Lines 78-84 subtest 'existing_statuses() tests' => sub { Link Here
78
78
79
    my $backend_req_status = $builder->build_object(
79
    my $backend_req_status = $builder->build_object(
80
        {
80
        {
81
            class => 'Koha::Illrequests',
81
            class => 'Koha::ILL::Requests',
82
            value => {
82
            value => {
83
                status       => 'READY',
83
                status       => 'READY',
84
                status_alias => undef,
84
                status_alias => undef,
Lines 90-96 subtest 'existing_statuses() tests' => sub { Link Here
90
90
91
    my $req = $builder->build_object(
91
    my $req = $builder->build_object(
92
        {
92
        {
93
            class => 'Koha::Illrequests',
93
            class => 'Koha::ILL::Requests',
94
            value => {
94
            value => {
95
                status       => 'REQ',
95
                status       => 'REQ',
96
                status_alias => undef,
96
                status_alias => undef,
Lines 101-107 subtest 'existing_statuses() tests' => sub { Link Here
101
    );
101
    );
102
    my $chk = $builder->build_object(
102
    my $chk = $builder->build_object(
103
        {
103
        {
104
            class => 'Koha::Illrequests',
104
            class => 'Koha::ILL::Requests',
105
            value => {
105
            value => {
106
                status       => 'CHK',
106
                status       => 'CHK',
107
                status_alias => undef,
107
                status_alias => undef,
Lines 112-118 subtest 'existing_statuses() tests' => sub { Link Here
112
    );
112
    );
113
    my $bob = $builder->build_object(
113
    my $bob = $builder->build_object(
114
        {
114
        {
115
            class => 'Koha::Illrequests',
115
            class => 'Koha::ILL::Requests',
116
            value => {
116
            value => {
117
                status       => 'REQ',
117
                status       => 'REQ',
118
                status_alias => 'BOB',
118
                status_alias => 'BOB',
Lines 123-129 subtest 'existing_statuses() tests' => sub { Link Here
123
    );
123
    );
124
    my $req2 = $builder->build_object(
124
    my $req2 = $builder->build_object(
125
        {
125
        {
126
            class => 'Koha::Illrequests',
126
            class => 'Koha::ILL::Requests',
127
            value => {
127
            value => {
128
                status       => 'REQ',
128
                status       => 'REQ',
129
                status_alias => undef,
129
                status_alias => undef,
(-)a/t/db_dependent/Koha/ILL/Batch.t (-1 / +1 lines)
Lines 35-41 subtest 'ill_batch() tests' => sub { Link Here
35
    $schema->storage->txn_begin;
35
    $schema->storage->txn_begin;
36
36
37
    my $batch   = $builder->build_object( { class => 'Koha::ILL::Batches' } );
37
    my $batch   = $builder->build_object( { class => 'Koha::ILL::Batches' } );
38
    my $request = $builder->build_object( { class => 'Koha::Illrequests', value => { batch_id => undef } } );
38
    my $request = $builder->build_object( { class => 'Koha::ILL::Requests', value => { batch_id => undef } } );
39
39
40
    is( $request->ill_batch, undef, 'Not having a linked batch makes the method return undef' );
40
    is( $request->ill_batch, undef, 'Not having a linked batch makes the method return undef' );
41
41
(-)a/t/db_dependent/Koha/ILL/Batches.t (-2 / +2 lines)
Lines 20-26 use Modern::Perl; Link Here
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::ILL::Batch;
21
use Koha::ILL::Batch;
22
use Koha::ILL::Batches;
22
use Koha::ILL::Batches;
23
use Koha::Illrequests;
23
use Koha::ILL::Requests;
24
use Koha::Patrons;
24
use Koha::Patrons;
25
use t::lib::Mocks;
25
use t::lib::Mocks;
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
Lines 73-79 my $illrq = $builder->build( Link Here
73
        }
73
        }
74
    }
74
    }
75
);
75
);
76
my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} );
76
my $illrq_obj = Koha::ILL::Requests->find( $illrq->{illrequest_id} );
77
77
78
# Check patron
78
# Check patron
79
my $batch_patron = $illbatch->patron;
79
my $batch_patron = $illbatch->patron;
(-)a/t/db_dependent/Koha/ILL/Comments.t (-4 / +4 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use File::Basename qw/basename/;
20
use File::Basename qw/basename/;
21
use Koha::Database;
21
use Koha::Database;
22
use Koha::Illrequests;
22
use Koha::ILL::Requests;
23
use Koha::ILL::Request::Attributes;
23
use Koha::ILL::Request::Attributes;
24
use Koha::ILL::Request::Config;
24
use Koha::ILL::Request::Config;
25
use Koha::Patrons;
25
use Koha::Patrons;
Lines 37-43 use_ok('Koha::ILL::Comments'); Link Here
37
37
38
$schema->storage->txn_begin;
38
$schema->storage->txn_begin;
39
39
40
Koha::Illrequests->search->delete;
40
Koha::ILL::Requests->search->delete;
41
41
42
# Create a patron
42
# Create a patron
43
my $patron = $builder->build({ source => 'Borrower' });
43
my $patron = $builder->build({ source => 'Borrower' });
Lines 47-54 my $illrq = $builder->build({ Link Here
47
    source => 'Illrequest',
47
    source => 'Illrequest',
48
    value => { borrowernumber => $patron->{borrowernumber} }
48
    value => { borrowernumber => $patron->{borrowernumber} }
49
});
49
});
50
my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
50
my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
51
isa_ok( $illrq_obj, 'Koha::Illrequest' );
51
isa_ok( $illrq_obj, 'Koha::ILL::Request' );
52
52
53
# Create a librarian
53
# Create a librarian
54
my $librarian = $builder->build({ source => 'Borrower' });
54
my $librarian = $builder->build({ source => 'Borrower' });
(-)a/t/db_dependent/Koha/Illrequest.t (-3 / +3 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 1;
23
23
24
use Koha::Illrequests;
24
use Koha::ILL::Requests;
25
25
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
27
27
Lines 36-48 subtest 'patron() tests' => sub { Link Here
36
36
37
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
37
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
38
    my $request =
38
    my $request =
39
        $builder->build_object( { class => 'Koha::Illrequests', value => { borrowernumber => $patron->id } } );
39
        $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } );
40
40
41
    my $req_patron = $request->patron;
41
    my $req_patron = $request->patron;
42
    is( ref($req_patron), 'Koha::Patron' );
42
    is( ref($req_patron), 'Koha::Patron' );
43
    is( $req_patron->id,  $patron->id );
43
    is( $req_patron->id,  $patron->id );
44
44
45
    $request = $builder->build_object( { class => 'Koha::Illrequests', value => { borrowernumber => undef } } );
45
    $request = $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => undef } } );
46
46
47
    is( $request->patron, undef );
47
    is( $request->patron, undef );
48
48
(-)a/t/db_dependent/Illrequests.t (-26 / +57 lines)
Lines 41-52 use Test::Exception; Link Here
41
use Test::Deep qw/ cmp_deeply ignore /;
41
use Test::Deep qw/ cmp_deeply ignore /;
42
use Test::Warn;
42
use Test::Warn;
43
43
44
use Test::More tests => 15;
44
use Test::More tests => 16;
45
45
46
my $schema = Koha::Database->new->schema;
46
my $schema = Koha::Database->new->schema;
47
my $builder = t::lib::TestBuilder->new;
47
my $builder = t::lib::TestBuilder->new;
48
use_ok('Koha::Illrequest');
48
use_ok('Koha::ILL::Request');
49
use_ok('Koha::Illrequests');
49
use_ok('Koha::ILL::Requests');
50
50
51
subtest 'Basic object tests' => sub {
51
subtest 'Basic object tests' => sub {
52
52
Lines 54-64 subtest 'Basic object tests' => sub { Link Here
54
54
55
    $schema->storage->txn_begin;
55
    $schema->storage->txn_begin;
56
56
57
    Koha::Illrequests->search->delete;
57
    Koha::ILL::Requests->search->delete;
58
    my $illrq = $builder->build({ source => 'Illrequest' });
58
    my $illrq = $builder->build({ source => 'Illrequest' });
59
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
59
    my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
60
60
61
    isa_ok($illrq_obj, 'Koha::Illrequest',
61
    isa_ok($illrq_obj, 'Koha::ILL::Request',
62
           "Correctly create and load an illrequest object.");
62
           "Correctly create and load an illrequest object.");
63
    isa_ok($illrq_obj->_config, 'Koha::ILL::Request::Config',
63
    isa_ok($illrq_obj->_config, 'Koha::ILL::Request::Config',
64
           "Created a config object as part of Illrequest creation.");
64
           "Created a config object as part of Illrequest creation.");
Lines 119-125 subtest 'Basic object tests' => sub { Link Here
119
119
120
    $illrq_obj->delete;
120
    $illrq_obj->delete;
121
121
122
    is(Koha::Illrequests->search->count, 0,
122
    is(Koha::ILL::Requests->search->count, 0,
123
       "No illrequest found after delete.");
123
       "No illrequest found after delete.");
124
124
125
    $schema->storage->txn_rollback;
125
    $schema->storage->txn_rollback;
Lines 130-143 subtest 'store borrowernumber change also updates holds' => sub { Link Here
130
130
131
    $schema->storage->txn_begin;
131
    $schema->storage->txn_begin;
132
132
133
    Koha::Illrequests->search->delete;
133
    Koha::ILL::Requests->search->delete;
134
134
135
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
135
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
136
    my $other_patron = $builder->build_object({ class => 'Koha::Patrons' });
136
    my $other_patron = $builder->build_object({ class => 'Koha::Patrons' });
137
    my $biblio = $builder->build_object({ class => 'Koha::Biblios' });
137
    my $biblio = $builder->build_object({ class => 'Koha::Biblios' });
138
138
139
    my $request = $builder->build_object({
139
    my $request = $builder->build_object({
140
        class => 'Koha::Illrequests',
140
        class => 'Koha::ILL::Requests',
141
        value => {
141
        value => {
142
            borrowernumber => $patron->borrowernumber,
142
            borrowernumber => $patron->borrowernumber,
143
            biblio_id => $biblio->biblionumber,
143
            biblio_id => $biblio->biblionumber,
Lines 170-182 subtest 'store borrowernumber change also updates holds' => sub { Link Here
170
    is( $request->borrowernumber, $other_patron->borrowernumber,
170
    is( $request->borrowernumber, $other_patron->borrowernumber,
171
       'after change, changed borrowernumber found in illrequests' );
171
       'after change, changed borrowernumber found in illrequests' );
172
172
173
    my $new_request = Koha::Illrequest->new({
173
    my $new_request = Koha::ILL::Request->new({
174
        biblio_id => $biblio->biblionumber,
174
        biblio_id => $biblio->biblionumber,
175
        branchcode => $patron->branchcode,
175
        branchcode => $patron->branchcode,
176
    })->borrowernumber( $patron->borrowernumber )->store;
176
    })->borrowernumber( $patron->borrowernumber )->store;
177
177
178
    is( $new_request->borrowernumber, $patron->borrowernumber,
178
    is( $new_request->borrowernumber, $patron->borrowernumber,
179
       'Koha::Illrequest->new()->store() works as expected');
179
       'Koha::ILL::Request->new()->store() works as expected');
180
180
181
    my $new_holds_found = Koha::Holds->search({
181
    my $new_holds_found = Koha::Holds->search({
182
        biblionumber => $new_request->biblio_id,
182
        biblionumber => $new_request->biblio_id,
Lines 197-203 subtest 'Working with related objects' => sub { Link Here
197
197
198
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
198
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
199
    my $illrq  = $builder->build_object(
199
    my $illrq  = $builder->build_object(
200
        {   class => 'Koha::Illrequests',
200
        {   class => 'Koha::ILL::Requests',
201
            value => { borrowernumber => $patron->id, biblio_id => undef }
201
            value => { borrowernumber => $patron->id, biblio_id => undef }
202
        }
202
        }
203
    );
203
    );
Lines 228-234 subtest 'Working with related objects' => sub { Link Here
228
    is( $illrq->biblio, undef, "->biblio returns undef if no biblio" );
228
    is( $illrq->biblio, undef, "->biblio returns undef if no biblio" );
229
    my $biblio  = $builder->build_object( { class => 'Koha::Biblios' } );
229
    my $biblio  = $builder->build_object( { class => 'Koha::Biblios' } );
230
    my $req_bib = $builder->build_object(
230
    my $req_bib = $builder->build_object(
231
        {   class => 'Koha::Illrequests',
231
        {   class => 'Koha::ILL::Requests',
232
            value => { biblio_id => $biblio->biblionumber }
232
            value => { biblio_id => $biblio->biblionumber }
233
        }
233
        }
234
    );
234
    );
Lines 249-255 subtest 'Status Graph tests' => sub { Link Here
249
    $schema->storage->txn_begin;
249
    $schema->storage->txn_begin;
250
250
251
    my $illrq = $builder->build({source => 'Illrequest'});
251
    my $illrq = $builder->build({source => 'Illrequest'});
252
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
252
    my $illrq_obj = Koha::ILL::Requests->find($ illrq->{illrequest_id}) ;
253
253
254
    # _core_status_graph tests: it's just a constant, so here we just make
254
    # _core_status_graph tests: it's just a constant, so here we just make
255
    # sure it returns a hashref.
255
    # sure it returns a hashref.
Lines 314-320 subtest 'Status Graph tests' => sub { Link Here
314
    my $new_graph = $illrq_obj->_status_graph_union( $new_node, $illrq_obj->_core_status_graph);
314
    my $new_graph = $illrq_obj->_status_graph_union( $new_node, $illrq_obj->_core_status_graph);
315
    # Compare the updated graph to the expected graph
315
    # Compare the updated graph to the expected graph
316
    # The structure we compare against here is just a copy of the structure found
316
    # The structure we compare against here is just a copy of the structure found
317
    # in Koha::Illrequest::_core_status_graph() + the new node we created above
317
    # in Koha::ILL::Request::_core_status_graph() + the new node we created above
318
    cmp_deeply( $new_graph,
318
    cmp_deeply( $new_graph,
319
        {
319
        {
320
        TEST => {
320
        TEST => {
Lines 438-444 subtest 'Status Graph tests' => sub { Link Here
438
    my $dupe_graph = $illrq_obj->_status_graph_union( $illrq_obj->_core_status_graph, $dupe_node);
438
    my $dupe_graph = $illrq_obj->_status_graph_union( $illrq_obj->_core_status_graph, $dupe_node);
439
    # Compare the updated graph to the expected graph
439
    # Compare the updated graph to the expected graph
440
    # The structure we compare against here is just a copy of the structure found
440
    # The structure we compare against here is just a copy of the structure found
441
    # in Koha::Illrequest::_core_status_graph() + the new node we created above
441
    # in Koha::ILL::Request::_core_status_graph() + the new node we created above
442
    cmp_deeply( $dupe_graph,
442
    cmp_deeply( $dupe_graph,
443
        {
443
        {
444
        NEW => {
444
        NEW => {
Lines 561-567 subtest 'Backend testing (mocks)' => sub { Link Here
561
561
562
    my $patron = $builder->build({ source => 'Borrower' });
562
    my $patron = $builder->build({ source => 'Borrower' });
563
    my $illrq = $builder->build_object({
563
    my $illrq = $builder->build_object({
564
        class => 'Koha::Illrequests',
564
        class => 'Koha::ILL::Requests',
565
    });
565
    });
566
566
567
    $illrq->_backend($backend);
567
    $illrq->_backend($backend);
Lines 706-712 subtest 'Backend core methods' => sub { Link Here
706
                        { default => { count => 0, method => 'active' } });
706
                        { default => { count => 0, method => 'active' } });
707
707
708
    my $illrq = $builder->build_object({
708
    my $illrq = $builder->build_object({
709
        class => 'Koha::Illrequests',
709
        class => 'Koha::ILL::Requests',
710
        value => { backend => undef }
710
        value => { backend => undef }
711
    });
711
    });
712
    $illrq->_config($config);
712
    $illrq->_config($config);
Lines 944-950 subtest 'Helpers' => sub { Link Here
944
        source => 'Illrequest',
944
        source => 'Illrequest',
945
        value => { branchcode => "HDE", borrowernumber => $patron->{borrowernumber} }
945
        value => { branchcode => "HDE", borrowernumber => $patron->{borrowernumber} }
946
    });
946
    });
947
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
947
    my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
948
    $illrq_obj->_config($config);
948
    $illrq_obj->_config($config);
949
    $illrq_obj->_backend($backend);
949
    $illrq_obj->_backend($backend);
950
950
Lines 1168-1174 subtest 'Censorship' => sub { Link Here
1168
    $config->set_always('backend_dir', "/tmp");
1168
    $config->set_always('backend_dir', "/tmp");
1169
1169
1170
    my $illrq = $builder->build({source => 'Illrequest'});
1170
    my $illrq = $builder->build({source => 'Illrequest'});
1171
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
1171
    my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
1172
    $illrq_obj->_config($config);
1172
    $illrq_obj->_config($config);
1173
    $illrq_obj->_backend($backend);
1173
    $illrq_obj->_backend($backend);
1174
1174
Lines 1203-1209 subtest 'Checking out' => sub { Link Here
1203
    my $biblio = $builder->build_sample_biblio();
1203
    my $biblio = $builder->build_sample_biblio();
1204
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1204
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1205
    my $request = $builder->build_object({
1205
    my $request = $builder->build_object({
1206
        class => 'Koha::Illrequests',
1206
        class => 'Koha::ILL::Requests',
1207
        value => {
1207
        value => {
1208
            borrowernumber => $patron->borrowernumber,
1208
            borrowernumber => $patron->borrowernumber,
1209
            biblio_id      => $biblio->biblionumber
1209
            biblio_id      => $biblio->biblionumber
Lines 1330-1336 subtest 'Checking out with custom due date' => sub { Link Here
1330
        }
1330
        }
1331
    });
1331
    });
1332
    my $request = $builder->build_object({
1332
    my $request = $builder->build_object({
1333
        class => 'Koha::Illrequests',
1333
        class => 'Koha::ILL::Requests',
1334
        value => {
1334
        value => {
1335
            borrowernumber => $patron->borrowernumber,
1335
            borrowernumber => $patron->borrowernumber,
1336
            biblio_id      => $biblio->biblionumber
1336
            biblio_id      => $biblio->biblionumber
Lines 1365-1371 subtest 'Checking Limits' => sub { Link Here
1365
    $config->set_always('backend_dir', "/tmp");
1365
    $config->set_always('backend_dir', "/tmp");
1366
1366
1367
    my $illrq = $builder->build({source => 'Illrequest'});
1367
    my $illrq = $builder->build({source => 'Illrequest'});
1368
    my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
1368
    my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
1369
    $illrq_obj->_config($config);
1369
    $illrq_obj->_config($config);
1370
    $illrq_obj->_backend($backend);
1370
    $illrq_obj->_backend($backend);
1371
1371
Lines 1554-1560 subtest 'Custom statuses' => sub { Link Here
1554
1554
1555
    my $ill_req = $builder->build_object(
1555
    my $ill_req = $builder->build_object(
1556
        {
1556
        {
1557
            class => 'Koha::Illrequests',
1557
            class => 'Koha::ILL::Requests',
1558
            value => {
1558
            value => {
1559
                status_alias => $av->authorised_value
1559
                status_alias => $av->authorised_value
1560
            }
1560
            }
Lines 1565-1571 subtest 'Custom statuses' => sub { Link Here
1565
1565
1566
    $ill_req->status("COMP");
1566
    $ill_req->status("COMP");
1567
    is($ill_req->statusalias, undef,
1567
    is($ill_req->statusalias, undef,
1568
        "Koha::Illrequest->status overloading resetting status_alias");
1568
        "Koha::ILL::Request->status overloading resetting status_alias");
1569
1569
1570
    $schema->storage->txn_rollback;
1570
    $schema->storage->txn_rollback;
1571
};
1571
};
Lines 1596-1602 subtest 'Checking in hook' => sub { Link Here
1596
1596
1597
    my $illrq = $builder->build_object(
1597
    my $illrq = $builder->build_object(
1598
        {
1598
        {
1599
            class => 'Koha::Illrequests',
1599
            class => 'Koha::ILL::Requests',
1600
            value => {
1600
            value => {
1601
                biblio_id => $item->biblio->biblionumber,
1601
                biblio_id => $item->biblio->biblionumber,
1602
                status    => 'NEW'
1602
                status    => 'NEW'
Lines 1628-1630 subtest 'Checking in hook' => sub { Link Here
1628
1628
1629
    $schema->storage->txn_rollback;
1629
    $schema->storage->txn_rollback;
1630
};
1630
};
1631
1632
subtest 'filter_by_visible() tests' => sub {
1633
1634
    plan tests => 4;
1635
1636
    $schema->storage->txn_begin;
1637
1638
    my $req =
1639
        $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'REQ', biblio_id => undef } } );
1640
    my $chk =
1641
        $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'CHK', biblio_id => undef } } );
1642
    my $ret =
1643
        $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'RET', biblio_id => undef } } );
1644
1645
    my $reqs_rs = Koha::ILL::Requests->search( { illrequest_id => [ $req->id, $chk->id, $ret->id ] } );
1646
1647
    is( $reqs_rs->count, 3, 'Count is correct' );
1648
1649
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', '' );
1650
1651
    is( $reqs_rs->filter_by_visible->count, 3, 'No hidden statuses, same count' );
1652
1653
    t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'CHK|RET' );
1654
1655
    my $filtered_reqs = $reqs_rs->filter_by_visible;
1656
1657
    is( $filtered_reqs->count, 1, 'Count is correct' );
1658
    is( $filtered_reqs->next->status, 'REQ' );
1659
1660
    $schema->storage->txn_rollback;
1661
};
(-)a/t/db_dependent/Koha/Illrequests.t (-62 lines)
Lines 1-62 Link Here
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::Illrequests;
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 'filter_by_visible() tests' => sub {
33
34
    plan tests => 4;
35
36
    $schema->storage->txn_begin;
37
38
    my $req = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'REQ', biblio_id => undef } });
39
    my $chk = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'CHK', biblio_id => undef } });
40
    my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET', biblio_id => undef } });
41
42
    my $reqs_rs = Koha::Illrequests->search(
43
        {
44
            illrequest_id => [ $req->id, $chk->id, $ret->id ]
45
        }
46
    );
47
48
    is( $reqs_rs->count, 3, 'Count is correct' );
49
50
    t::lib::Mocks::mock_preference('ILLHiddenRequestStatuses', '');
51
52
    is( $reqs_rs->filter_by_visible->count, 3, 'No hidden statuses, same count' );
53
54
    t::lib::Mocks::mock_preference('ILLHiddenRequestStatuses', 'CHK|RET');
55
56
    my $filtered_reqs = $reqs_rs->filter_by_visible;
57
58
    is( $filtered_reqs->count, 1, 'Count is correct' );
59
    is( $filtered_reqs->next->status, 'REQ' );
60
61
    $schema->storage->txn_rollback;
62
};
(-)a/t/db_dependent/api/v1/ill_backends.t (-7 / +7 lines)
Lines 27-33 use t::lib::TestBuilder; Link Here
27
use t::lib::Mocks;
27
use t::lib::Mocks;
28
28
29
use Koha::AuthorisedValueCategories;
29
use Koha::AuthorisedValueCategories;
30
use Koha::Illrequests;
30
use Koha::ILL::Requests;
31
31
32
my $schema  = Koha::Database->new->schema;
32
my $schema  = Koha::Database->new->schema;
33
my $builder = t::lib::TestBuilder->new;
33
my $builder = t::lib::TestBuilder->new;
Lines 80-94 subtest 'list() tests' => sub { Link Here
80
        }
80
        }
81
    );
81
    );
82
82
83
    # Mock Koha::Illrequest::load_backend (to load Mocked Backend)
83
    # Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
84
    my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
84
    my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
85
    $illreqmodule->mock( 'load_backend',
85
    $illreqmodule->mock( 'load_backend',
86
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
86
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
87
    );
87
    );
88
88
89
    $schema->storage->txn_begin;
89
    $schema->storage->txn_begin;
90
90
91
    Koha::Illrequests->search->delete;
91
    Koha::ILL::Requests->search->delete;
92
92
93
    # create an authorized user
93
    # create an authorized user
94
    my $librarian = $builder->build_object(
94
    my $librarian = $builder->build_object(
Lines 169-189 subtest 'list() tests' => sub { Link Here
169
    # Create some ILL requests
169
    # Create some ILL requests
170
    my $backend_status_req = $builder->build_object(
170
    my $backend_status_req = $builder->build_object(
171
        {
171
        {
172
            class => 'Koha::Illrequests',
172
            class => 'Koha::ILL::Requests',
173
            value =>
173
            value =>
174
              { status => $backend_status->{code}, backend => $backend->name }
174
              { status => $backend_status->{code}, backend => $backend->name }
175
        }
175
        }
176
    );
176
    );
177
    my $core_status_req = $builder->build_object(
177
    my $core_status_req = $builder->build_object(
178
        {
178
        {
179
            class => 'Koha::Illrequests',
179
            class => 'Koha::ILL::Requests',
180
            value =>
180
            value =>
181
              { status => $core_status->{code}, backend => $backend->name }
181
              { status => $core_status->{code}, backend => $backend->name }
182
        }
182
        }
183
    );
183
    );
184
    my $alias_status_req = $builder->build_object(
184
    my $alias_status_req = $builder->build_object(
185
        {
185
        {
186
            class => 'Koha::Illrequests',
186
            class => 'Koha::ILL::Requests',
187
            value => {
187
            value => {
188
                status       => $core_status->{code},
188
                status       => $core_status->{code},
189
                backend      => $backend->name,
189
                backend      => $backend->name,
(-)a/t/db_dependent/api/v1/ill_batches.t (-2 / +2 lines)
Lines 27-33 use JSON qw(encode_json); Link Here
27
27
28
use Koha::ILL::Batch;
28
use Koha::ILL::Batch;
29
use Koha::ILL::Batches;
29
use Koha::ILL::Batches;
30
use Koha::Illrequests;
30
use Koha::ILL::Requests;
31
use Koha::ILL::Batch::Statuses;
31
use Koha::ILL::Batch::Statuses;
32
use Koha::Database;
32
use Koha::Database;
33
33
Lines 81-87 subtest 'list() tests' => sub { Link Here
81
81
82
    my $illrq = $builder->build_object(
82
    my $illrq = $builder->build_object(
83
        {
83
        {
84
            class => 'Koha::Illrequests',
84
            class => 'Koha::ILL::Requests',
85
            value => {
85
            value => {
86
                batch_id       => $batch_1->id,
86
                batch_id       => $batch_1->id,
87
                borrowernumber => $librarian->id,
87
                borrowernumber => $librarian->id,
(-)a/t/db_dependent/api/v1/ill_requests.t (-13 / +12 lines)
Lines 29-35 use t::lib::TestBuilder; Link Here
29
use t::lib::Mocks;
29
use t::lib::Mocks;
30
30
31
use Koha::AuthorisedValueCategories;
31
use Koha::AuthorisedValueCategories;
32
use Koha::Illrequests;
32
use Koha::ILL::Requests;
33
use Koha::DateUtils qw( format_sqldatetime );
33
use Koha::DateUtils qw( format_sqldatetime );
34
34
35
my $schema  = Koha::Database->new->schema;
35
my $schema  = Koha::Database->new->schema;
Lines 62-76 subtest 'list() tests' => sub { Link Here
62
        'status_graph', sub {},
62
        'status_graph', sub {},
63
    );
63
    );
64
64
65
    # Mock Koha::Illrequest::load_backend (to load Mocked Backend)
65
    # Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
66
    my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
66
    my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
67
    $illreqmodule->mock( 'load_backend',
67
    $illreqmodule->mock( 'load_backend',
68
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
68
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
69
    );
69
    );
70
70
71
    $schema->storage->txn_begin;
71
    $schema->storage->txn_begin;
72
72
73
    Koha::Illrequests->search->delete;
73
    Koha::ILL::Requests->search->delete;
74
74
75
    # create an authorized user
75
    # create an authorized user
76
    my $librarian = $builder->build_object(
76
    my $librarian = $builder->build_object(
Lines 141-147 subtest 'list() tests' => sub { Link Here
141
    # Create some ILL requests
141
    # Create some ILL requests
142
    my $req_1 = $builder->build_object(
142
    my $req_1 = $builder->build_object(
143
        {
143
        {
144
            class => 'Koha::Illrequests',
144
            class => 'Koha::ILL::Requests',
145
            value => {
145
            value => {
146
                borrowernumber => $patron->borrowernumber,
146
                borrowernumber => $patron->borrowernumber,
147
                batch_id       => undef,
147
                batch_id       => undef,
Lines 153-159 subtest 'list() tests' => sub { Link Here
153
    );
153
    );
154
    my $req_2 = $builder->build_object(
154
    my $req_2 = $builder->build_object(
155
        {
155
        {
156
            class => 'Koha::Illrequests',
156
            class => 'Koha::ILL::Requests',
157
            value => {
157
            value => {
158
                batch_id     => undef,
158
                batch_id     => undef,
159
                status       => $request_status->{code},
159
                status       => $request_status->{code},
Lines 164-170 subtest 'list() tests' => sub { Link Here
164
164
165
        }
165
        }
166
    );
166
    );
167
    my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET' } });
167
    my $ret = $builder->build_object({ class => 'Koha::ILL::Requests', value => { status => 'RET' } });
168
168
169
    # Three requests exist, expect all three to be returned
169
    # Three requests exist, expect all three to be returned
170
    $t->get_ok("//$userid:$password@/api/v1/ill/requests")
170
    $t->get_ok("//$userid:$password@/api/v1/ill/requests")
Lines 282-288 subtest 'add() tests' => sub { Link Here
282
    # Create an ILL request
282
    # Create an ILL request
283
    my $illrequest = $builder->build_object(
283
    my $illrequest = $builder->build_object(
284
        {
284
        {
285
            class => 'Koha::Illrequests',
285
            class => 'Koha::ILL::Requests',
286
            value => {
286
            value => {
287
                backend        => 'Mock',
287
                backend        => 'Mock',
288
                branchcode     => $library->branchcode,
288
                branchcode     => $library->branchcode,
Lines 311-318 subtest 'add() tests' => sub { Link Here
311
        'status_graph', sub {},
311
        'status_graph', sub {},
312
    );
312
    );
313
313
314
    # Mock Koha::Illrequest::load_backend (to load Mocked Backend)
314
    # Mock Koha::ILL::Request::load_backend (to load Mocked Backend)
315
    my $illreqmodule = Test::MockModule->new('Koha::Illrequest');
315
    my $illreqmodule = Test::MockModule->new('Koha::ILL::Request');
316
    $illreqmodule->mock(
316
    $illreqmodule->mock(
317
        'load_backend',
317
        'load_backend',
318
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
318
        sub { my $self = shift; $self->{_my_backend} = $backend; return $self }
Lines 340-346 subtest 'add() tests' => sub { Link Here
340
340
341
                    my $api_req = $builder->build_object(
341
                    my $api_req = $builder->build_object(
342
                        {
342
                        {
343
                            class => 'Koha::Illrequests',
343
                            class => 'Koha::ILL::Requests',
344
                            value => {
344
                            value => {
345
                                borrowernumber => $patron->borrowernumber,
345
                                borrowernumber => $patron->borrowernumber,
346
                                batch_id       => undef,
346
                                batch_id       => undef,
Lines 360-366 subtest 'add() tests' => sub { Link Here
360
360
361
    $schema->storage->txn_begin;
361
    $schema->storage->txn_begin;
362
362
363
    Koha::Illrequests->search->delete;
363
    Koha::ILL::Requests->search->delete;
364
364
365
    my $body = {
365
    my $body = {
366
        ill_backend_id => 'Mock',
366
        ill_backend_id => 'Mock',
367
- 

Return to bug 35581