From ac157b7a75d84a07002e7c9cecceb549b612cf98 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 15 Dec 2023 10:07:11 +0000 Subject: [PATCH] Bug 35581: Koha::Illrequest -> Koha::ILL::Request Koha/Illrequests.pm -> Koha/ILL/Requests.pm Merged: t/db_dependent/Koha/Illrequests.t t/db_dependent/Illrequests.t Into: t/db_dependent/Koha/ILL/Requests.t ILL classes file structure is, for the most part, around 7 years old and doesn't follow a strict logic. It's so confusing that some test files exist redundantly. This housekeeping should help future work in regards to ISO18626 to add Koha as a supplying agency instead of just requesting agency, as is now. It should also help future housekeeping of moving backend related logic out of the Illrequest.pm into Illbackend.pm (now ILL/Request.pm and ILL/Backend.pm as of this patchset). It should also help in structuring the addition of a master generic form (see bug 35570) This patchset will require existing backends to be updated to match the new class names and structure, if they invoke them. Test plan, k-t-d, run tests: prove t/db_dependent/api/v1/ill_* prove t/db_dependent/Koha/ILL/* Test plan, k-t-d, manual: 1) Install FreeForm, enable ILL module, run: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 2) You'll have to switch the FreeForm repo to the one compatible with this work, like: cd /kohadevbox/koha/Koha/Illbackends/FreeForm git checkout reorganize_ILL 3) Do some generic ILL testing: 3.1) Create a request 3.2) Add a comment to a request 3.3) Edit a request 3.4) Edit a request's item metadata 3.5) Confirm a request 3.6) List requests 3.7) Filter requests list using left side filters 4) Install a metadata enrichment plugin: https://github.com/PTFS-Europe/koha-plugin-api-pubmed 4.1) Create an ILL batch and insert a pubmedid like 123 4.2) Add the request and finish batch 5) Verify all of the above works as expected Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- C4/Circulation.pm | 6 +- C4/Letters.pm | 2 +- Koha/Biblio.pm | 6 +- Koha/ILL/Backend.pm | 4 +- Koha/ILL/Batch.pm | 6 +- Koha/{Illrequest.pm => ILL/Request.pm} | 12 +-- Koha/ILL/Request/Attribute.pm | 4 +- Koha/ILL/Request/SupplierUpdateProcessor.pm | 8 +- Koha/ILL/Request/Workflow/TypeDisclaimer.pm | 6 +- Koha/{Illrequests.pm => ILL/Requests.pm} | 12 +-- Koha/REST/V1/ILL/Backends.pm | 6 +- Koha/REST/V1/ILL/Batches.pm | 2 +- Koha/REST/V1/Illrequests.pm | 12 +-- Koha/Schema/Result/Illrequest.pm | 8 ++ catalogue/detail.pl | 4 +- ill/ill-requests.pl | 40 ++++----- members/ill-requests.pl | 2 +- misc/process_ill_updates.pl | 4 +- opac/opac-illrequests.pl | 14 ++-- t/db_dependent/Biblio.t | 4 +- t/db_dependent/Circulation.t | 4 +- t/db_dependent/Illrequest/Availability.t | 6 +- t/db_dependent/Illrequest/SupplierUpdate.t | 2 +- .../Illrequest/SupplierUpdateProcessor.t | 8 +- t/db_dependent/Illrequest/TypeDisclaimer.t | 6 +- t/db_dependent/Koha/Biblio.t | 4 +- t/db_dependent/Koha/ILL/Backend.t | 16 ++-- t/db_dependent/Koha/ILL/Batch.t | 2 +- t/db_dependent/Koha/ILL/Batches.t | 4 +- t/db_dependent/Koha/ILL/Comments.t | 8 +- .../Koha/{Illrequest.t => ILL/Request.t} | 6 +- .../{Illrequests.t => Koha/ILL/Requests.t} | 83 +++++++++++++------ t/db_dependent/Koha/Illrequests.t | 62 -------------- t/db_dependent/Koha/Plugins/Ill_hooks.t | 2 +- t/db_dependent/api/v1/ill_backends.t | 14 ++-- t/db_dependent/api/v1/ill_batches.t | 4 +- t/db_dependent/api/v1/ill_requests.t | 24 +++--- 37 files changed, 197 insertions(+), 220 deletions(-) rename Koha/{Illrequest.pm => ILL/Request.pm} (99%) rename Koha/{Illrequests.pm => ILL/Requests.pm} (90%) rename t/db_dependent/Koha/{Illrequest.t => ILL/Request.t} (91%) rename t/db_dependent/{Illrequests.t => Koha/ILL/Requests.t} (96%) delete mode 100755 t/db_dependent/Koha/Illrequests.t diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a62a1acf63..52f2330967 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -44,7 +44,7 @@ use Koha::Biblioitems; use Koha::DateUtils qw( dt_from_string ); use Koha::Calendar; use Koha::Checkouts; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::Items; use Koha::Patrons; use Koha::Patron::Debarments qw( DelUniqueDebarment AddUniqueDebarment ); @@ -1604,7 +1604,7 @@ sub AddIssue { # Check if we need to use an exact due date set by the ILL module if ( C4::Context->preference('ILLModule') ) { # Check if there is an ILL connected with the biblio of the item we are issuing - my $ill_request = Koha::Illrequests->search({ + my $ill_request = Koha::ILL::Requests->search({ biblio_id => $item_object->biblionumber, borrowernumber => $patron->borrowernumber, completed => undef, @@ -2489,7 +2489,7 @@ sub AddReturn { # Check if this item belongs to a biblio record that is attached to an # ILL request, if it is we need to update the ILL request's status if ( $doreturn and C4::Context->preference('CirculateILL')) { - my $request = Koha::Illrequests->find( + my $request = Koha::ILL::Requests->find( { biblio_id => $item->biblio->biblionumber } ); $request->status('RET') if $request; diff --git a/C4/Letters.pm b/C4/Letters.pm index cceda4be1c..af5af484b1 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -1861,7 +1861,7 @@ sub _get_tt_params { fk => 'verification_token', }, illrequests => { - module => 'Koha::Illrequests', + module => 'Koha::ILL::Requests', singular => 'illrequest', plural => 'illrequests', pk => 'illrequest_id' diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 771af6c167..684f9b700c 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -47,7 +47,7 @@ use Koha::Bookings; use Koha::Checkouts; use Koha::CirculationRules; use Koha::Exceptions; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::Item::Transfer::Limits; use Koha::Items; use Koha::Libraries; @@ -178,7 +178,7 @@ sub tickets { my $ill_requests = $biblio->ill_requests(); -Returns a Koha::Illrequests object +Returns a Koha::ILL::Requests object =cut @@ -186,7 +186,7 @@ sub ill_requests { my ( $self ) = @_; my $ill_requests = $self->_result->ill_requests; - return Koha::Illrequests->_new_from_dbic($ill_requests); + return Koha::ILL::Requests->_new_from_dbic($ill_requests); } =head3 item_groups diff --git a/Koha/ILL/Backend.pm b/Koha/ILL/Backend.pm index 1c71232050..287c59679e 100644 --- a/Koha/ILL/Backend.pm +++ b/Koha/ILL/Backend.pm @@ -55,7 +55,7 @@ sub existing_statuses { # throw 'Koha::Exceptions::Ill::InvalidBackendId' when we're converting to a Koha object. # Finally, to get around 'ONLY_FULL_GROUP_BY', we have to be explicit about which # 'request_id' we want to return, hense the 'MAX' call. - my $ill_requests = Koha::Illrequests->search( + my $ill_requests = Koha::ILL::Requests->search( { backend => $backend_id }, { select => [ 'status', \'MAX(illrequest_id)', 'backend' ], @@ -79,7 +79,7 @@ sub existing_statuses { } # Now do the same to get all status_aliases - $ill_requests = Koha::Illrequests->search( + $ill_requests = Koha::ILL::Requests->search( { backend => $backend_id }, { select => [ 'status_alias', \'MAX(illrequest_id)', 'backend' ], diff --git a/Koha/ILL/Batch.pm b/Koha/ILL/Batch.pm index 76330dd51c..659598b3d0 100644 --- a/Koha/ILL/Batch.pm +++ b/Koha/ILL/Batch.pm @@ -21,7 +21,7 @@ use Modern::Perl; use Koha::Database; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::ILL::Request::Logger; use Koha::ILL::Batch::Statuses; use Koha::Libraries; @@ -81,14 +81,14 @@ sub library { =head3 requests -Return the I for this batch +Return the I for this batch =cut sub requests { my ($self) = @_; my $requests = $self->_result->requests; - return Koha::Illrequests->_new_from_dbic($requests); + return Koha::ILL::Requests->_new_from_dbic($requests); } =head3 create_and_log diff --git a/Koha/Illrequest.pm b/Koha/ILL/Request.pm similarity index 99% rename from Koha/Illrequest.pm rename to Koha/ILL/Request.pm index ed437e473f..0b1b52aadb 100644 --- a/Koha/Illrequest.pm +++ b/Koha/ILL/Request.pm @@ -1,4 +1,4 @@ -package Koha::Illrequest; +package Koha::ILL::Request; # Copyright PTFS Europe 2016,2018 # @@ -49,11 +49,11 @@ use base qw(Koha::Object); =head1 NAME -Koha::Illrequest - Koha Illrequest Object class +Koha::ILL::Request - Koha Illrequest Object class =head1 (Re)Design -An ILLRequest consists of two parts; the Illrequest Koha::Object, and a series +An ILLRequest consists of two parts; the ILL::Request Koha::Object, and a series of related Illrequestattributes. The former encapsulates the basic necessary information that any ILL requires @@ -1272,7 +1272,7 @@ sub _limit_counter { # Establish parameters of counts my $resultset; if ($method && $method eq 'annual') { - $resultset = Koha::Illrequests->search({ + $resultset = Koha::ILL::Requests->search({ -and => [ %{$target}, \"YEAR(placed) = YEAR(NOW())" @@ -1282,7 +1282,7 @@ sub _limit_counter { # XXX: This status list is ugly. There should be a method in config # to return these. my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } }; - $resultset = Koha::Illrequests->search({ %{$target}, %{$where} }); + $resultset = Koha::ILL::Requests->search( { %{$target}, %{$where} } ); } # Fetch counts @@ -2108,7 +2108,7 @@ sub strings_map { =head3 get_op_param_deprecation - my $op = Koha::Illrequest->check_url_param_deprecation($params); + my $op = $req->check_url_param_deprecation($params); Issues a deprecation message for the given parameters, if needed. Returns the appropriate operation based on the interface type. diff --git a/Koha/ILL/Request/Attribute.pm b/Koha/ILL/Request/Attribute.pm index ce1b47fd04..a761ab8c62 100644 --- a/Koha/ILL/Request/Attribute.pm +++ b/Koha/ILL/Request/Attribute.pm @@ -49,13 +49,13 @@ sub store { =head3 request -Returns a Koha::Illrequest object representing the core request. +Returns a Koha::ILL::Request object representing the core request . =cut sub request { my ($self) = @_; - return Koha::Illrequest->_new_from_dbic( $self->_result->illrequest ); + return Koha::ILL::Request->_new_from_dbic( $self->_result->illrequest ); } =head2 Internal methods diff --git a/Koha/ILL/Request/SupplierUpdateProcessor.pm b/Koha/ILL/Request/SupplierUpdateProcessor.pm index 69d3233fb3..aaedbadc9b 100644 --- a/Koha/ILL/Request/SupplierUpdateProcessor.pm +++ b/Koha/ILL/Request/SupplierUpdateProcessor.pm @@ -21,7 +21,7 @@ use Modern::Perl; =head1 NAME -Koha::Illrequest::SupplierUpdateProcessor - Represents a SupplerUpdate processor +Koha::ILL::Request::SupplierUpdateProcessor - Represents a SupplerUpdate processor =head1 SYNOPSIS @@ -40,12 +40,12 @@ a SupplierUpdate =head3 new - my $processor = Koha::Illrequest::SupplierUpdateProcessor->new( + my $processor = Koha::ILL::Request::SupplierUpdateProcessor->new( $target_source_type, $target_source_name ); -Create a new Koha::Illrequest::SupplierUpdateProcessor object. +Create a new Koha::ILL::Request::SupplierUpdateProcessor object . =cut @@ -64,7 +64,7 @@ sub new { =head3 run - Koha::Illrequest::SupplierUpdateProcessor->run(); + Koha::ILL::Request::SupplierUpdateProcessor->run(); Runs the processor diff --git a/Koha/ILL/Request/Workflow/TypeDisclaimer.pm b/Koha/ILL/Request/Workflow/TypeDisclaimer.pm index 9d222780d4..73c4639459 100644 --- a/Koha/ILL/Request/Workflow/TypeDisclaimer.pm +++ b/Koha/ILL/Request/Workflow/TypeDisclaimer.pm @@ -25,7 +25,7 @@ use base qw(Koha::ILL::Request::Workflow); =head1 NAME -Koha::Illrequest::TypeDisclaimer - Koha ILL TypeDisclaimer +Koha::ILL::Request::TypeDisclaimer - Koha ILL TypeDisclaimer =head1 SYNOPSIS @@ -43,7 +43,7 @@ and handle the template params accordingly =head3 show_type_disclaimer my $show_type_disclaimer = - Koha::Illrequest::TypeDisclaimer->show_type_disclaimer($params); + Koha::ILL::Request::TypeDisclaimer->show_type_disclaimer($params); Given $params, return true if type disclaimer should be shown @@ -83,7 +83,7 @@ sub show_type_disclaimer { =head3 type_disclaimer_template_params my $type_disclaimer_template_params = - Koha::Illrequest::TypeDisclaimer->type_disclaimer_template_params( + Koha::ILL::Request::TypeDisclaimer->type_disclaimer_template_params( $params); Given $params, return true if type disclaimer should be rendered diff --git a/Koha/Illrequests.pm b/Koha/ILL/Requests.pm similarity index 90% rename from Koha/Illrequests.pm rename to Koha/ILL/Requests.pm index 2146c1e491..468bd34d82 100644 --- a/Koha/Illrequests.pm +++ b/Koha/ILL/Requests.pm @@ -1,4 +1,4 @@ -package Koha::Illrequests; +package Koha::ILL::Requests; # Copyright PTFS Europe 2016 # @@ -20,14 +20,14 @@ package Koha::Illrequests; use Modern::Perl; use Koha::Database; -use Koha::Illrequest; +use Koha::ILL::Request; use Koha::ILL::Request::Config; use base qw(Koha::Objects); =head1 NAME -Koha::Illrequests - Koha Illrequests Object class +Koha::ILL::Requests - Koha Illrequests Object class =head1 API @@ -37,7 +37,7 @@ Koha::Illrequests - Koha Illrequests Object class =head3 new - my $illRequests = Koha::Illrequests->new(); + my $illRequests = Koha::ILL::Requests->new(); Create an ILLREQUESTS object, a singleton through which we can interact with ILLREQUEST objects stored in the database or search for ILL candidates at API @@ -60,7 +60,7 @@ sub new { my $visible_requests = $requests->filter_by_visible; -Returns a I resultset, filtered by statuses that are not listed +Returns a I resultset, filtered by statuses that are not listed as hidden in the I system preference. =cut @@ -121,7 +121,7 @@ sub _type { =cut sub object_class { - return 'Koha::Illrequest'; + return 'Koha::ILL::Request'; } =head1 AUTHOR diff --git a/Koha/REST/V1/ILL/Backends.pm b/Koha/REST/V1/ILL/Backends.pm index d2b78d008c..85e3a9c425 100644 --- a/Koha/REST/V1/ILL/Backends.pm +++ b/Koha/REST/V1/ILL/Backends.pm @@ -20,7 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::ILL::Request::Config; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::ILL::Backend; =head1 NAME @@ -44,7 +44,7 @@ sub list { my @data; foreach my $b (@$backends) { - my $backend = Koha::Illrequest->new->load_backend($b); + my $backend = Koha::ILL::Request->new->load_backend($b); my $embed = $backend_module->embed( $b, @@ -76,7 +76,7 @@ sub get { #FIXME: Should we move load_backend into Koha::ILL::Backend... # or maybe make Koha::Ill::Backend a base class for all # backends? - my $backend = Koha::Illrequest->new->load_backend($backend_id); + my $backend = Koha::ILL::Request->new->load_backend($backend_id); my $backend_module = Koha::ILL::Backend->new; diff --git a/Koha/REST/V1/ILL/Batches.pm b/Koha/REST/V1/ILL/Batches.pm index ab79e0d483..df1389f9ab 100644 --- a/Koha/REST/V1/ILL/Batches.pm +++ b/Koha/REST/V1/ILL/Batches.pm @@ -21,7 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; use Koha::ILL::Batches; use Koha::ILL::Batch::Statuses; -use Koha::Illrequests; +use Koha::ILL::Requests; use Try::Tiny qw( catch try ); diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 229c8d5fa1..6f5b67fed1 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -20,7 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use C4::Context; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::ILL::Request::Attributes; use Koha::Libraries; use Koha::Patrons; @@ -38,7 +38,7 @@ Koha::REST::V1::Illrequests =head3 list -Controller function that handles listing Koha::Illrequest objects +Controller function that handles listing Koha::ILL::Request objects =cut @@ -47,7 +47,7 @@ sub list { return try { - my $reqs = $c->objects->search(Koha::Illrequests->new->filter_by_visible); + my $reqs = $c->objects->search(Koha::ILL::Requests->new->filter_by_visible); return $c->render( status => 200, @@ -77,7 +77,7 @@ sub add { $body->{borrowernumber} = delete $body->{patron_id}; $body->{branchcode} = delete $body->{library_id}; - my $request = Koha::Illrequest->new->load_backend( $body->{backend} ); + my $request = Koha::ILL::Request->new->load_backend( $body->{backend} ); my $create_api = $request->_backend->capabilities('create_api'); @@ -93,7 +93,7 @@ sub add { my $create_result = &{$create_api}($body, $request); my $new_id = $create_result->illrequest_id; - my $new_req = Koha::Illrequests->find($new_id); + my $new_req = Koha::ILL::Requests->find($new_id); $c->res->headers->location($c->req->url->to_string . '/' . $new_req->illrequest_id); return $c->render( @@ -105,7 +105,7 @@ sub add { } catch { - my $to_api_mapping = Koha::Illrequest->new->to_api_mapping; + my $to_api_mapping = Koha::ILL::Request->new->to_api_mapping; if ( blessed $_ ) { if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) { diff --git a/Koha/Schema/Result/Illrequest.pm b/Koha/Schema/Result/Illrequest.pm index ccfbe880ee..98d68f700b 100644 --- a/Koha/Schema/Result/Illrequest.pm +++ b/Koha/Schema/Result/Illrequest.pm @@ -439,4 +439,12 @@ __PACKAGE__->belongs_to( }, ); +sub koha_object_class { + 'Koha::ILL::Request'; +} + +sub koha_objects_class { + 'Koha::ILL::Requests'; +} + 1; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index f3ae21949f..bf72787d44 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -50,7 +50,7 @@ use Koha::Biblio::ItemGroup::Items; use Koha::Biblio::ItemGroups; use Koha::CoverImages; use Koha::DateUtils; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; @@ -455,7 +455,7 @@ $template->param( holdcount => $holds->count ); # Check if there are any ILL requests connected to the biblio my $illrequests = C4::Context->preference('ILLModule') - ? Koha::Illrequests->search( { biblio_id => $biblionumber } ) + ? Koha::ILL::Requests->search( { biblio_id => $biblionumber } ) : []; $template->param( illrequests => $illrequests ); diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index cfe3df65fc..3d7744ca56 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -26,8 +26,8 @@ use C4::Output qw( output_and_exit output_html_with_http_headers ); use Koha::Notice::Templates; use Koha::AuthorisedValues; use Koha::ILL::Comment; -use Koha::Illrequests; -use Koha::Illrequest; +use Koha::ILL::Requests; +use Koha::ILL::Request; use Koha::ILL::Batches; use Koha::ILL::Request::Workflow::Availability; use Koha::ILL::Request::Workflow::TypeDisclaimer; @@ -39,7 +39,7 @@ use URI::Escape qw( uri_escape_utf8 ); use JSON qw( encode_json ); our $cgi = CGI->new; -my $illRequests = Koha::Illrequests->new; +my $illRequests = Koha::ILL::Requests->new; # Grab all passed data # 'our' since Plack changes the scoping @@ -52,7 +52,7 @@ unless ( C4::Context->preference('ILLModule') ) { exit; } -my $op = Koha::Illrequest->get_op_param_deprecation( 'intranet', $params ); +my $op = Koha::ILL::Request->get_op_param_deprecation( 'intranet', $params ); my ( $template, $patronnumber, $cookie ) = get_template_and_user( { template_name => 'ill/ill-requests.tt', @@ -91,7 +91,7 @@ if ( $backends_available ) { if ( $op eq 'illview' ) { # View the details of an ILL - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); # Get the details for notices that can be sent from here my $notices = Koha::Notice::Templates->search( @@ -124,7 +124,7 @@ if ( $backends_available ) { } elsif ( $op eq 'cud-create' ) { # Load the ILL backend - my $request = Koha::Illrequest->new->load_backend( $params->{backend} ); + my $request = Koha::ILL::Request->new->load_backend( $params->{backend} ); # Before request creation operations - Preparation my $availability = @@ -161,7 +161,7 @@ if ( $backends_available ) { } } elsif ( $op eq 'migrate' ) { # We're in the process of migrating a request - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $backend_result; if ( $params->{backend} ) { $backend_result = $request->backend_migrate($params); @@ -192,7 +192,7 @@ if ( $backends_available ) { } elsif ( $op eq 'confirm' ) { # Backend 'confirm' method # confirm requires a specific request, so first, find it. - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $backend_result = $request->backend_confirm($params); $template->param( whole => $backend_result, @@ -205,7 +205,7 @@ if ( $backends_available ) { } elsif ( $op eq 'cud-cancel' ) { # Backend 'cancel' method # cancel requires a specific request, so first, find it. - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $backend_result = $request->backend_cancel($params); $template->param( whole => $backend_result, @@ -220,7 +220,7 @@ if ( $backends_available ) { # (not the Illrequestattributes) # We simulate the API for backend requests for uniformity. # So, init: - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $batches = Koha::ILL::Batches->search(undef, { order_by => { -asc => 'name' } }); @@ -273,7 +273,7 @@ if ( $backends_available ) { redirect_to_list(); } elsif ( $op eq 'delete_confirm') { - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); $template->param( request => $request @@ -285,7 +285,7 @@ if ( $backends_available ) { # to the confirmation view if ($params->{confirmed}) { # We simply delete the request... - Koha::Illrequests->find( $params->{illrequest_id} )->delete; + Koha::ILL::Requests->find( $params->{illrequest_id} )->delete; # ... then return to list view. redirect_to_list(); } else { @@ -297,7 +297,7 @@ if ( $backends_available ) { } } elsif ( $op eq 'mark_completed' ) { - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $backend_result = $request->mark_completed($params); $template->param( whole => $backend_result, @@ -312,7 +312,7 @@ if ( $backends_available ) { my $backend_result; my $request; try { - $request = Koha::Illrequests->find($params->{illrequest_id}); + $request = Koha::ILL::Requests->find($params->{illrequest_id}); $params->{current_branchcode} = C4::Context->mybranch; $backend_result = $request->generic_confirm($params); @@ -369,7 +369,7 @@ if ( $backends_available ) { # handle special commit rules & update type handle_commit_maybe($backend_result, $request); } elsif ( $op eq 'cud-check_out') { - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find($params->{illrequest_id}); my $backend_result = $request->check_out($params); $template->param( params => $params, @@ -409,9 +409,9 @@ if ( $backends_available ) { } } - $template->param( table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ) ) + $template->param( table_actions => encode_json( Koha::ILL::Request->get_staff_table_actions ) ); } elsif ( $op eq "cud-save_comment" ) { - my $comment = Koha::Illcomment->new({ + my $comment = Koha::ILL::Comment->new({ illrequest_id => scalar $params->{illrequest_id}, borrowernumber => $patronnumber, comment => scalar $params->{comment}, @@ -425,7 +425,7 @@ if ( $backends_available ) { } elsif ( $op eq "send_notice" ) { my $illrequest_id = $params->{illrequest_id}; - my $request = Koha::Illrequests->find($illrequest_id); + my $request = Koha::ILL::Requests->find($illrequest_id); my $ret = $request->send_patron_notice($params->{notice_code}); my $append = ''; if ($ret->{result} && scalar @{$ret->{result}->{success}} > 0) { @@ -446,7 +446,7 @@ if ( $backends_available ) { # Do not remove, it prevents us falling through to the 'else' } else { $op =~ s/^cud-//; - my $request = Koha::Illrequests->find($params->{illrequest_id}); + my $request = Koha::ILL::Requests->find( $params->{illrequest_id} ); my $backend_result = $request->custom_capability($op, $params); $template->param( whole => $backend_result, @@ -522,7 +522,7 @@ sub have_batch_backends { # FIXME: This should be moved to Koha::Illbackend sub can_batch { my ( $backend ) = @_; - my $request = Koha::Illrequest->new->load_backend( $backend ); + my $request = Koha::ILL::Request->new->load_backend( $backend ); return $request->_backend_capability( 'provides_batch_requests' ); } diff --git a/members/ill-requests.pl b/members/ill-requests.pl index d4573fabf3..8162abd6cb 100755 --- a/members/ill-requests.pl +++ b/members/ill-requests.pl @@ -46,7 +46,7 @@ $template->param( prefilters => "borrowernumber=$borrowernumber", patron => $patron, illview => 1, - table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ), + table_actions => encode_json( Koha::ILL::Request->get_staff_table_actions ), ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/misc/process_ill_updates.pl b/misc/process_ill_updates.pl index 3acba3d47f..a773eb8480 100755 --- a/misc/process_ill_updates.pl +++ b/misc/process_ill_updates.pl @@ -22,7 +22,7 @@ use Getopt::Long qw( GetOptions ); use POSIX; use Koha::Script; -use Koha::Illrequests; +use Koha::ILL::Requests; # Command line option values my $get_help = 0; @@ -96,7 +96,7 @@ if (scalar @status_alias_arr > 0) { debug_msg("DBIC WHERE:"); debug_msg($where); -my $requests = Koha::Illrequests->search($where); +my $requests = Koha::ILL::Requests->search($where); debug_msg("Processing " . $requests->count . " requests"); diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index d531955b4a..92f3e5e4f6 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -28,8 +28,8 @@ use C4::Output qw( output_html_with_http_headers ); use POSIX qw( strftime ); use Koha::ILL::Request::Config; -use Koha::Illrequests; -use Koha::Illrequest; +use Koha::ILL::Requests; +use Koha::ILL::Request; use Koha::Libraries; use Koha::Patrons; use Koha::ILL::Request::Workflow::Availability; @@ -61,11 +61,11 @@ my $backends_available = ( scalar @{$backends} > 0 ); $template->param( backends_available => $backends_available ); my $patron = Koha::Patrons->find($loggedinuser); -my $op = Koha::Illrequest->get_op_param_deprecation( 'opac', $params ); +my $op = Koha::ILL::Request->get_op_param_deprecation( 'opac', $params ); my ( $illrequest_id, $request ); if ( $illrequest_id = $params->{illrequest_id} ) { - $request = Koha::Illrequests->find($illrequest_id); + $request = Koha::ILL::Requests->find($illrequest_id); # Make sure the request belongs to the logged in user if( !$request || $request->borrowernumber != $loggedinuser ) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); @@ -80,7 +80,7 @@ if ( ( $op eq 'cud-create' || $op eq 'cancreq' || $op eq 'cud-update' ) && !$pat if ( $op eq 'list' ) { - my $requests = Koha::Illrequests->search( + my $requests = Koha::ILL::Requests->search( { borrowernumber => $loggedinuser } ); $template->param( @@ -111,12 +111,12 @@ if ( $op eq 'list' ) { exit; } elsif ( $op eq 'cud-create' ) { if (!$params->{backend}) { - my $req = Koha::Illrequest->new; + my $req = Koha::ILL::Request->new; $template->param( backends => $req->available_backends ); } else { - my $request = Koha::Illrequest->new + my $request = Koha::ILL::Request->new ->load_backend($params->{backend}); # Before request creation operations - Preparation diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index e8813b78cd..6848f7094c 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -718,8 +718,8 @@ subtest 'DelBiblio' => sub { { class => 'Koha::Acquisition::Orders', value => $orderinfo } ); # Add some ILL requests - my $ill_req_1 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); - my $ill_req_2 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); + my $ill_req_1 = $builder->build_object({ class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); + my $ill_req_2 = $builder->build_object({ class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); C4::Biblio::DelBiblio($biblio->biblionumber); # Or $biblio->delete is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' ); diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 5e88a29a00..b9e8244168 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -2424,7 +2424,7 @@ subtest 'AddIssue & illrequests.due_date' => sub { my $custom_date_due = '9999-12-18 12:34:56'; my $expected_date_due = '9999-12-18 23:59:00'; - my $illrequest = Koha::Illrequest->new({ + my $illrequest = Koha::ILL::Request->new({ borrowernumber => $patron->borrowernumber, biblio_id => $item->biblionumber, branchcode => $library->{'branchcode'}, @@ -2438,7 +2438,7 @@ subtest 'AddIssue & illrequests.due_date' => sub { $item = $builder->build_sample_item(); $custom_date_due = '9999-12-19'; $expected_date_due = '9999-12-19 23:59:00'; - $illrequest = Koha::Illrequest->new({ + $illrequest = Koha::ILL::Request->new({ borrowernumber => $patron->borrowernumber, biblio_id => $item->biblionumber, branchcode => $library->{'branchcode'}, diff --git a/t/db_dependent/Illrequest/Availability.t b/t/db_dependent/Illrequest/Availability.t index 8482c30a9d..d80dca387a 100755 --- a/t/db_dependent/Illrequest/Availability.t +++ b/t/db_dependent/Illrequest/Availability.t @@ -75,8 +75,8 @@ $backend->mock( ); $backend->mock( 'status_graph', sub { }, ); -# Mock Koha::Illrequest::load_backend (to load Mocked Backend) -my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); +# Mock Koha::ILL::Request::load_backend (to load Mocked Backend) +my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } ); @@ -90,7 +90,7 @@ $availability_module->mock( 'get_services', [ { name => 'service' } ] ); my $req_1 = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => {} } ); diff --git a/t/db_dependent/Illrequest/SupplierUpdate.t b/t/db_dependent/Illrequest/SupplierUpdate.t index 281c1df5f4..00dcfe3fc3 100755 --- a/t/db_dependent/Illrequest/SupplierUpdate.t +++ b/t/db_dependent/Illrequest/SupplierUpdate.t @@ -19,7 +19,7 @@ use Modern::Perl; use Test::MockObject; -use Koha::Illrequest; +use Koha::ILL::Request; use Koha::ILL::Request::SupplierUpdate; use Test::More tests => 4; diff --git a/t/db_dependent/Illrequest/SupplierUpdateProcessor.t b/t/db_dependent/Illrequest/SupplierUpdateProcessor.t index 5577fb417c..d4110f30bd 100755 --- a/t/db_dependent/Illrequest/SupplierUpdateProcessor.t +++ b/t/db_dependent/Illrequest/SupplierUpdateProcessor.t @@ -17,20 +17,20 @@ use Modern::Perl; -use Koha::Illrequest::SupplierUpdateProcessor; +use Koha::ILL::Request::SupplierUpdateProcessor; use Test::More tests => 3; use Test::Warn; -my $processor = Koha::Illrequest::SupplierUpdateProcessor->new( +my $processor = Koha::ILL::Request::SupplierUpdateProcessor->new( 'test_type', 'test_name', 'Test processor name' ); -use_ok('Koha::Illrequest::SupplierUpdateProcessor'); +use_ok('Koha::ILL::Request::SupplierUpdateProcessor'); -isa_ok( $processor, 'Koha::Illrequest::SupplierUpdateProcessor' ); +isa_ok( $processor, 'Koha::ILL::Request::SupplierUpdateProcessor' ); warning_like { $processor->run() diff --git a/t/db_dependent/Illrequest/TypeDisclaimer.t b/t/db_dependent/Illrequest/TypeDisclaimer.t index 123a865772..d24734e002 100755 --- a/t/db_dependent/Illrequest/TypeDisclaimer.t +++ b/t/db_dependent/Illrequest/TypeDisclaimer.t @@ -75,8 +75,8 @@ $backend->mock( ); $backend->mock( 'status_graph', sub { }, ); -# Mock Koha::Illrequest::load_backend (to load Mocked Backend) -my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); +# Mock Koha::ILL::Request::load_backend (to load Mocked Backend) +my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } ); @@ -96,7 +96,7 @@ article: my $req_1 = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => {} } ); diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index d6cd9995d4..eb528655e5 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -1439,13 +1439,13 @@ subtest 'ill_requests() tests' => sub { my $biblio = $builder->build_sample_biblio; my $rs = $biblio->ill_requests; - is( ref($rs), 'Koha::Illrequests' ); + is( ref($rs), 'Koha::ILL::Requests' ); is( $rs->count, 0, 'No linked requests' ); foreach ( 1..10 ) { $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->id } } ); diff --git a/t/db_dependent/Koha/ILL/Backend.t b/t/db_dependent/Koha/ILL/Backend.t index 8a59e16e05..b552eee297 100755 --- a/t/db_dependent/Koha/ILL/Backend.t +++ b/t/db_dependent/Koha/ILL/Backend.t @@ -34,7 +34,7 @@ subtest 'existing_statuses() tests' => sub { plan tests => 2; $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; # Mock external ILLBackend (as object) my $backend = Test::MockObject->new; @@ -58,8 +58,8 @@ subtest 'existing_statuses() tests' => sub { }, ); - # Mock Koha::Illrequest::load_backend (to load Mocked Backend) - my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); + # Mock Koha::ILL::Request::load_backend (to load Mocked Backend) + my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } @@ -78,7 +78,7 @@ subtest 'existing_statuses() tests' => sub { my $backend_req_status = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => 'READY', status_alias => undef, @@ -90,7 +90,7 @@ subtest 'existing_statuses() tests' => sub { my $req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => 'REQ', status_alias => undef, @@ -101,7 +101,7 @@ subtest 'existing_statuses() tests' => sub { ); my $chk = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => 'CHK', status_alias => undef, @@ -112,7 +112,7 @@ subtest 'existing_statuses() tests' => sub { ); my $bob = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => 'REQ', status_alias => 'BOB', @@ -123,7 +123,7 @@ subtest 'existing_statuses() tests' => sub { ); my $req2 = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => 'REQ', status_alias => undef, diff --git a/t/db_dependent/Koha/ILL/Batch.t b/t/db_dependent/Koha/ILL/Batch.t index 7d95e66df6..eaa6df4232 100755 --- a/t/db_dependent/Koha/ILL/Batch.t +++ b/t/db_dependent/Koha/ILL/Batch.t @@ -35,7 +35,7 @@ subtest 'ill_batch() tests' => sub { $schema->storage->txn_begin; my $batch = $builder->build_object( { class => 'Koha::ILL::Batches' } ); - my $request = $builder->build_object( { class => 'Koha::Illrequests', value => { batch_id => undef } } ); + my $request = $builder->build_object( { class => 'Koha::ILL::Requests', value => { batch_id => undef } } ); is( $request->ill_batch, undef, 'Not having a linked batch makes the method return undef' ); diff --git a/t/db_dependent/Koha/ILL/Batches.t b/t/db_dependent/Koha/ILL/Batches.t index e3e192ed54..8580f75dae 100755 --- a/t/db_dependent/Koha/ILL/Batches.t +++ b/t/db_dependent/Koha/ILL/Batches.t @@ -20,7 +20,7 @@ use Modern::Perl; use Koha::Database; use Koha::ILL::Batch; use Koha::ILL::Batches; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::Patrons; use t::lib::Mocks; use t::lib::TestBuilder; @@ -73,7 +73,7 @@ my $illrq = $builder->build( } } ); -my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} ); +my $illrq_obj = Koha::ILL::Requests->find( $illrq->{illrequest_id} ); # Check patron my $batch_patron = $illbatch->patron; diff --git a/t/db_dependent/Koha/ILL/Comments.t b/t/db_dependent/Koha/ILL/Comments.t index dbe1dd2c44..3e1016592d 100755 --- a/t/db_dependent/Koha/ILL/Comments.t +++ b/t/db_dependent/Koha/ILL/Comments.t @@ -19,7 +19,7 @@ use Modern::Perl; use File::Basename qw/basename/; use Koha::Database; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::ILL::Request::Attributes; use Koha::ILL::Request::Config; use Koha::Patrons; @@ -37,7 +37,7 @@ use_ok('Koha::ILL::Comments'); $schema->storage->txn_begin; -Koha::Illrequests->search->delete; +Koha::ILL::Requests->search->delete; # Create a patron my $patron = $builder->build( { source => 'Borrower' } ); @@ -49,8 +49,8 @@ my $illrq = $builder->build( value => { borrowernumber => $patron->{borrowernumber} } } ); -my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} ); -isa_ok( $illrq_obj, 'Koha::Illrequest' ); +my $illrq_obj = Koha::ILL::Requests->find( $illrq->{illrequest_id} ); +isa_ok( $illrq_obj, 'Koha::ILL::Request' ); # Create a librarian my $librarian = $builder->build( { source => 'Borrower' } ); diff --git a/t/db_dependent/Koha/Illrequest.t b/t/db_dependent/Koha/ILL/Request.t similarity index 91% rename from t/db_dependent/Koha/Illrequest.t rename to t/db_dependent/Koha/ILL/Request.t index d717963ec8..b0a747c98d 100755 --- a/t/db_dependent/Koha/Illrequest.t +++ b/t/db_dependent/Koha/ILL/Request.t @@ -21,7 +21,7 @@ use Modern::Perl; use Test::More tests => 3; -use Koha::Illrequests; +use Koha::ILL::Requests; use t::lib::TestBuilder; @@ -36,13 +36,13 @@ subtest 'patron() tests' => sub { my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $request = - $builder->build_object( { class => 'Koha::Illrequests', value => { borrowernumber => $patron->id } } ); + $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } ); my $req_patron = $request->patron; is( ref($req_patron), 'Koha::Patron' ); is( $req_patron->id, $patron->id ); - $request = $builder->build_object( { class => 'Koha::Illrequests', value => { borrowernumber => undef } } ); + $request = $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => undef } } ); is( $request->patron, undef ); diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Koha/ILL/Requests.t similarity index 96% rename from t/db_dependent/Illrequests.t rename to t/db_dependent/Koha/ILL/Requests.t index 48128f9960..464e5ce505 100755 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Koha/ILL/Requests.t @@ -41,12 +41,12 @@ use Test::Exception; use Test::Deep qw/ cmp_deeply ignore /; use Test::Warn; -use Test::More tests => 15; +use Test::More tests => 16; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -use_ok('Koha::Illrequest'); -use_ok('Koha::Illrequests'); +use_ok('Koha::ILL::Request'); +use_ok('Koha::ILL::Requests'); subtest 'Basic object tests' => sub { @@ -54,11 +54,11 @@ subtest 'Basic object tests' => sub { $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; my $illrq = $builder->build({ source => 'Illrequest' }); - my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); + my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id}); - isa_ok($illrq_obj, 'Koha::Illrequest', + isa_ok($illrq_obj, 'Koha::ILL::Request', "Correctly create and load an illrequest object."); isa_ok($illrq_obj->_config, 'Koha::ILL::Request::Config', "Created a config object as part of Illrequest creation."); @@ -119,7 +119,7 @@ subtest 'Basic object tests' => sub { $illrq_obj->delete; - is(Koha::Illrequests->search->count, 0, + is(Koha::ILL::Requests->search->count, 0, "No illrequest found after delete."); $schema->storage->txn_rollback; @@ -130,14 +130,14 @@ subtest 'store borrowernumber change also updates holds' => sub { $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $other_patron = $builder->build_object({ class => 'Koha::Patrons' }); my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); my $request = $builder->build_object({ - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->borrowernumber, biblio_id => $biblio->biblionumber, @@ -170,13 +170,13 @@ subtest 'store borrowernumber change also updates holds' => sub { is( $request->borrowernumber, $other_patron->borrowernumber, 'after change, changed borrowernumber found in illrequests' ); - my $new_request = Koha::Illrequest->new({ + my $new_request = Koha::ILL::Request->new({ biblio_id => $biblio->biblionumber, branchcode => $patron->branchcode, })->borrowernumber( $patron->borrowernumber )->store; is( $new_request->borrowernumber, $patron->borrowernumber, - 'Koha::Illrequest->new()->store() works as expected'); + 'Koha::ILL::Request->new()->store() works as expected'); my $new_holds_found = Koha::Holds->search({ biblionumber => $new_request->biblio_id, @@ -197,7 +197,7 @@ subtest 'Working with related objects' => sub { my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $illrq = $builder->build_object( - { class => 'Koha::Illrequests', + { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id, biblio_id => undef } } ); @@ -228,7 +228,7 @@ subtest 'Working with related objects' => sub { is( $illrq->biblio, undef, "->biblio returns undef if no biblio" ); my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); my $req_bib = $builder->build_object( - { class => 'Koha::Illrequests', + { class => 'Koha::ILL::Requests', value => { biblio_id => $biblio->biblionumber } } ); @@ -249,7 +249,7 @@ subtest 'Status Graph tests' => sub { $schema->storage->txn_begin; my $illrq = $builder->build({source => 'Illrequest'}); - my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); + my $illrq_obj = Koha::ILL::Requests->find($ illrq->{illrequest_id}) ; # _core_status_graph tests: it's just a constant, so here we just make # sure it returns a hashref. @@ -314,7 +314,7 @@ subtest 'Status Graph tests' => sub { my $new_graph = $illrq_obj->_status_graph_union( $new_node, $illrq_obj->_core_status_graph); # Compare the updated graph to the expected graph # The structure we compare against here is just a copy of the structure found - # in Koha::Illrequest::_core_status_graph() + the new node we created above + # in Koha::ILL::Request::_core_status_graph() + the new node we created above cmp_deeply( $new_graph, { TEST => { @@ -438,7 +438,7 @@ subtest 'Status Graph tests' => sub { my $dupe_graph = $illrq_obj->_status_graph_union( $illrq_obj->_core_status_graph, $dupe_node); # Compare the updated graph to the expected graph # The structure we compare against here is just a copy of the structure found - # in Koha::Illrequest::_core_status_graph() + the new node we created above + # in Koha::ILL::Request::_core_status_graph() + the new node we created above cmp_deeply( $dupe_graph, { NEW => { @@ -561,7 +561,7 @@ subtest 'Backend testing (mocks)' => sub { my $patron = $builder->build({ source => 'Borrower' }); my $illrq = $builder->build_object({ - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', }); $illrq->_backend($backend); @@ -706,7 +706,7 @@ subtest 'Backend core methods' => sub { { default => { count => 0, method => 'active' } }); my $illrq = $builder->build_object({ - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { backend => undef } }); $illrq->_config($config); @@ -944,7 +944,7 @@ subtest 'Helpers' => sub { source => 'Illrequest', value => { branchcode => "HDE", borrowernumber => $patron->{borrowernumber} } }); - my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); + my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id}); $illrq_obj->_config($config); $illrq_obj->_backend($backend); @@ -1168,7 +1168,7 @@ subtest 'Censorship' => sub { $config->set_always('backend_dir', "/tmp"); my $illrq = $builder->build({source => 'Illrequest'}); - my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); + my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id}); $illrq_obj->_config($config); $illrq_obj->_backend($backend); @@ -1203,7 +1203,7 @@ subtest 'Checking out' => sub { my $biblio = $builder->build_sample_biblio(); my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $request = $builder->build_object({ - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->borrowernumber, biblio_id => $biblio->biblionumber @@ -1330,7 +1330,7 @@ subtest 'Checking out with custom due date' => sub { } }); my $request = $builder->build_object({ - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->borrowernumber, biblio_id => $biblio->biblionumber @@ -1365,7 +1365,7 @@ subtest 'Checking Limits' => sub { $config->set_always('backend_dir', "/tmp"); my $illrq = $builder->build({source => 'Illrequest'}); - my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); + my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id}); $illrq_obj->_config($config); $illrq_obj->_backend($backend); @@ -1554,7 +1554,7 @@ subtest 'Custom statuses' => sub { my $ill_req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status_alias => $av->authorised_value } @@ -1565,7 +1565,7 @@ subtest 'Custom statuses' => sub { $ill_req->status("COMP"); is($ill_req->statusalias, undef, - "Koha::Illrequest->status overloading resetting status_alias"); + "Koha::ILL::Request->status overloading resetting status_alias"); $schema->storage->txn_rollback; }; @@ -1596,7 +1596,7 @@ subtest 'Checking in hook' => sub { my $illrq = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { biblio_id => $item->biblio->biblionumber, status => 'NEW' @@ -1628,3 +1628,34 @@ subtest 'Checking in hook' => sub { $schema->storage->txn_rollback; }; + +subtest 'filter_by_visible() tests' => sub { + + plan tests => 4; + + $schema->storage->txn_begin; + + my $req = + $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'REQ', biblio_id => undef } } ); + my $chk = + $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'CHK', biblio_id => undef } } ); + my $ret = + $builder->build_object( { class => 'Koha::ILL::Requests', value => { status => 'RET', biblio_id => undef } } ); + + my $reqs_rs = Koha::ILL::Requests->search( { illrequest_id => [ $req->id, $chk->id, $ret->id ] } ); + + is( $reqs_rs->count, 3, 'Count is correct' ); + + t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', '' ); + + is( $reqs_rs->filter_by_visible->count, 3, 'No hidden statuses, same count' ); + + t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'CHK|RET' ); + + my $filtered_reqs = $reqs_rs->filter_by_visible; + + is( $filtered_reqs->count, 1, 'Count is correct' ); + is( $filtered_reqs->next->status, 'REQ' ); + + $schema->storage->txn_rollback; +}; diff --git a/t/db_dependent/Koha/Illrequests.t b/t/db_dependent/Koha/Illrequests.t deleted file mode 100755 index b75c248c58..0000000000 --- a/t/db_dependent/Koha/Illrequests.t +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/perl - -# Copyright 2023 Koha Development team -# -# This file is part of Koha -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . - -use Modern::Perl; - -use Test::More tests => 1; - -use Koha::Illrequests; - -use t::lib::TestBuilder; -use t::lib::Mocks; - -my $builder = t::lib::TestBuilder->new; -my $schema = Koha::Database->new->schema; - -subtest 'filter_by_visible() tests' => sub { - - plan tests => 4; - - $schema->storage->txn_begin; - - my $req = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'REQ', biblio_id => undef } }); - my $chk = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'CHK', biblio_id => undef } }); - my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET', biblio_id => undef } }); - - my $reqs_rs = Koha::Illrequests->search( - { - illrequest_id => [ $req->id, $chk->id, $ret->id ] - } - ); - - is( $reqs_rs->count, 3, 'Count is correct' ); - - t::lib::Mocks::mock_preference('ILLHiddenRequestStatuses', ''); - - is( $reqs_rs->filter_by_visible->count, 3, 'No hidden statuses, same count' ); - - t::lib::Mocks::mock_preference('ILLHiddenRequestStatuses', 'CHK|RET'); - - my $filtered_reqs = $reqs_rs->filter_by_visible; - - is( $filtered_reqs->count, 1, 'Count is correct' ); - is( $filtered_reqs->next->status, 'REQ' ); - - $schema->storage->txn_rollback; -}; diff --git a/t/db_dependent/Koha/Plugins/Ill_hooks.t b/t/db_dependent/Koha/Plugins/Ill_hooks.t index 5b420fffc5..a2be67380a 100755 --- a/t/db_dependent/Koha/Plugins/Ill_hooks.t +++ b/t/db_dependent/Koha/Plugins/Ill_hooks.t @@ -47,7 +47,7 @@ subtest 'ill_table_actions hook' => sub { my $plugins = Koha::Plugins->new; $plugins->InstallPlugins; - my $table_actions = Koha::Illrequest->get_staff_table_actions; + my $table_actions = Koha::ILL::Request->get_staff_table_actions; is_deeply( $table_actions, diff --git a/t/db_dependent/api/v1/ill_backends.t b/t/db_dependent/api/v1/ill_backends.t index ded2424fc1..58ac8e9d77 100755 --- a/t/db_dependent/api/v1/ill_backends.t +++ b/t/db_dependent/api/v1/ill_backends.t @@ -27,7 +27,7 @@ use t::lib::TestBuilder; use t::lib::Mocks; use Koha::AuthorisedValueCategories; -use Koha::Illrequests; +use Koha::ILL::Requests; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -80,15 +80,15 @@ subtest 'list() tests' => sub { } ); - # Mock Koha::Illrequest::load_backend (to load Mocked Backend) - my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); + # Mock Koha::ILL::Request::load_backend (to load Mocked Backend) + my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } ); $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; # create an authorized user my $librarian = $builder->build_object( @@ -169,21 +169,21 @@ subtest 'list() tests' => sub { # Create some ILL requests my $backend_status_req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => $backend_status->{code}, backend => $backend->name } } ); my $core_status_req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => $core_status->{code}, backend => $backend->name } } ); my $alias_status_req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { status => $core_status->{code}, backend => $backend->name, diff --git a/t/db_dependent/api/v1/ill_batches.t b/t/db_dependent/api/v1/ill_batches.t index 3dda9cc467..ed744a80ac 100755 --- a/t/db_dependent/api/v1/ill_batches.t +++ b/t/db_dependent/api/v1/ill_batches.t @@ -27,7 +27,7 @@ use JSON qw(encode_json); use Koha::ILL::Batch; use Koha::ILL::Batches; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::ILL::Batch::Statuses; use Koha::Database; @@ -81,7 +81,7 @@ subtest 'list() tests' => sub { my $illrq = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { batch_id => $batch_1->id, borrowernumber => $librarian->id, diff --git a/t/db_dependent/api/v1/ill_requests.t b/t/db_dependent/api/v1/ill_requests.t index 9745c5cf91..a2260a23d3 100755 --- a/t/db_dependent/api/v1/ill_requests.t +++ b/t/db_dependent/api/v1/ill_requests.t @@ -29,7 +29,7 @@ use t::lib::TestBuilder; use t::lib::Mocks; use Koha::AuthorisedValueCategories; -use Koha::Illrequests; +use Koha::ILL::Requests; use Koha::DateUtils qw( format_sqldatetime ); my $schema = Koha::Database->new->schema; @@ -62,15 +62,15 @@ subtest 'list() tests' => sub { 'status_graph', sub {}, ); - # Mock Koha::Illrequest::load_backend (to load Mocked Backend) - my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); + # Mock Koha::ILL::Request::load_backend (to load Mocked Backend) + my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } ); $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; # create an authorized user my $librarian = $builder->build_object( @@ -141,7 +141,7 @@ subtest 'list() tests' => sub { # Create some ILL requests my $req_1 = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->borrowernumber, batch_id => undef, @@ -153,7 +153,7 @@ subtest 'list() tests' => sub { ); my $req_2 = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { batch_id => undef, status => $request_status->{code}, @@ -164,7 +164,7 @@ subtest 'list() tests' => sub { } ); - my $ret = $builder->build_object({ class => 'Koha::Illrequests', value => { status => 'RET' } }); + my $ret = $builder->build_object({ class => 'Koha::ILL::Requests', value => { status => 'RET' } }); # Three requests exist, expect all three to be returned $t->get_ok("//$userid:$password@/api/v1/ill/requests") @@ -282,7 +282,7 @@ subtest 'add() tests' => sub { # Create an ILL request my $illrequest = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { backend => 'Mock', branchcode => $library->branchcode, @@ -311,8 +311,8 @@ subtest 'add() tests' => sub { 'status_graph', sub {}, ); - # Mock Koha::Illrequest::load_backend (to load Mocked Backend) - my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); + # Mock Koha::ILL::Request::load_backend (to load Mocked Backend) + my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); $illreqmodule->mock( 'load_backend', sub { my $self = shift; $self->{_my_backend} = $backend; return $self } @@ -340,7 +340,7 @@ subtest 'add() tests' => sub { my $api_req = $builder->build_object( { - class => 'Koha::Illrequests', + class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->borrowernumber, batch_id => undef, @@ -360,7 +360,7 @@ subtest 'add() tests' => sub { $schema->storage->txn_begin; - Koha::Illrequests->search->delete; + Koha::ILL::Requests->search->delete; my $body = { ill_backend_id => 'Mock', -- 2.39.5