From c766172d50c3384f35fb4068372a0df1b2e24b92 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 14 Dec 2023 14:41:07 -0100 Subject: [PATCH] Bug 35581: Koha::Illcomment* -> Koha::ILL::Comment* Koha/Illcomment.pm -> Koha/ILL/Comment.pm Koha/Illcomments.pm -> Koha/ILL/Comments.pm Signed-off-by: David Nind Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- Koha/{Illcomment.pm => ILL/Comment.pm} | 8 ++-- Koha/{Illcomments.pm => ILL/Comments.pm} | 12 ++--- Koha/Illrequest.pm | 8 ++-- ill/ill-requests.pl | 2 +- .../{Illcomments.t => Koha/ILL/Comments.t} | 46 ++++++++++--------- t/db_dependent/api/v1/ill_requests.t | 2 +- 6 files changed, 41 insertions(+), 37 deletions(-) rename Koha/{Illcomment.pm => ILL/Comment.pm} (87%) rename Koha/{Illcomments.pm => ILL/Comments.pm} (81%) rename t/db_dependent/{Illcomments.t => Koha/ILL/Comments.t} (67%) diff --git a/Koha/Illcomment.pm b/Koha/ILL/Comment.pm similarity index 87% rename from Koha/Illcomment.pm rename to Koha/ILL/Comment.pm index 594af5379c..7bd1f13f87 100644 --- a/Koha/Illcomment.pm +++ b/Koha/ILL/Comment.pm @@ -1,4 +1,4 @@ -package Koha::Illcomment; +package Koha::ILL::Comment; # Copyright Magnus Enger Libriotech 2017 # @@ -23,13 +23,13 @@ use base qw(Koha::Object); =head1 NAME -Koha::Illcomment - Koha Illcomment Object class +Koha::ILL::Comment - Koha Illcomment Object class =head2 Class methods =head3 patron - my $patron = Koha::Illcomment->patron; + my $patron = Koha::ILL::Comment->patron; Return the patron object associated with this comment @@ -46,7 +46,7 @@ sub patron { =head3 _type - my $type = Koha::IllComment->_type; + my $type = Koha::ILL::Comment->_type; Return this object's type diff --git a/Koha/Illcomments.pm b/Koha/ILL/Comments.pm similarity index 81% rename from Koha/Illcomments.pm rename to Koha/ILL/Comments.pm index 01d15884e7..3f9c29c89e 100644 --- a/Koha/Illcomments.pm +++ b/Koha/ILL/Comments.pm @@ -1,4 +1,4 @@ -package Koha::Illcomments; +package Koha::ILL::Comments; # Copyright Magnus Enger Libriotech 2017 # @@ -19,18 +19,18 @@ package Koha::Illcomments; use Modern::Perl; use Koha::Database; -use Koha::Illcomment; +use Koha::ILL::Comment; use base qw(Koha::Objects); =head1 NAME -Koha::Illcomments - Koha Illcomments Object class +Koha::ILL::Comments - Koha Illcomments Object class =head2 Internal methods =head3 _type - my $type = Koha::IllComments->_type; + my $type = Koha::ILL::Comments->_type; Return this object's type @@ -42,14 +42,14 @@ sub _type { =head3 object_class - my $class = Koha::IllComments->object_class; + my $class = Koha::ILL::Comments->object_class; Return this object's class name =cut sub object_class { - return 'Koha::Illcomment'; + return 'Koha::ILL::Comment'; } =head1 AUTHOR diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index e2853a648e..fbdddfc6bc 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -30,7 +30,7 @@ use Koha::Cache::Memory::Lite; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions::Ill; -use Koha::Illcomments; +use Koha::ILL::Comments; use Koha::Illrequestattributes; use Koha::AuthorisedValue; use Koha::Illrequest::Logger; @@ -209,7 +209,7 @@ sub illrequestattributes { sub illcomments { my ( $self ) = @_; - return Koha::Illcomments->_new_from_dbic( + return Koha::ILL::Comments->_new_from_dbic( scalar $self->_result->illcomments ); } @@ -218,13 +218,13 @@ sub illcomments { my $ill_comments = $req->comments; -Returns a I resultset for the linked comments. +Returns a I resultset for the linked comments. =cut sub comments { my ( $self ) = @_; - return Koha::Illcomments->_new_from_dbic( + return Koha::ILL::Comments->_new_from_dbic( scalar $self->_result->comments ); } diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 4586ee5ea3..2b709eabb1 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -25,7 +25,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_and_exit output_html_with_http_headers ); use Koha::Notice::Templates; use Koha::AuthorisedValues; -use Koha::Illcomment; +use Koha::ILL::Comment; use Koha::Illrequests; use Koha::Illrequest; use Koha::ILL::Batches; diff --git a/t/db_dependent/Illcomments.t b/t/db_dependent/Koha/ILL/Comments.t similarity index 67% rename from t/db_dependent/Illcomments.t rename to t/db_dependent/Koha/ILL/Comments.t index 85cc63021c..9cf6ebb1bd 100755 --- a/t/db_dependent/Illcomments.t +++ b/t/db_dependent/Koha/ILL/Comments.t @@ -30,54 +30,58 @@ use Test::MockModule; use Test::More tests => 9; -my $schema = Koha::Database->new->schema; +my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -use_ok('Koha::Illcomment'); -use_ok('Koha::Illcomments'); +use_ok('Koha::ILL::Comment'); +use_ok('Koha::ILL::Comments'); $schema->storage->txn_begin; Koha::Illrequests->search->delete; # Create a patron -my $patron = $builder->build({ source => 'Borrower' }); +my $patron = $builder->build( { source => 'Borrower' } ); # Create an ILL request -my $illrq = $builder->build({ - source => 'Illrequest', - value => { borrowernumber => $patron->{borrowernumber} } -}); -my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); +my $illrq = $builder->build( + { + source => 'Illrequest', + value => { borrowernumber => $patron->{borrowernumber} } + } +); +my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} ); isa_ok( $illrq_obj, 'Koha::Illrequest' ); # Create a librarian -my $librarian = $builder->build({ source => 'Borrower' }); +my $librarian = $builder->build( { source => 'Borrower' } ); # Create a comment and tie it to the request and the librarian my $comment_text = 'xyz'; -my $illcomment = $builder->build({ - source => 'Illcomment', - value => { - illrequest_id => $illrq_obj->illrequest_id, - borrowernumber => $librarian->{borrowernumber}, - comment => $comment_text, +my $illcomment = $builder->build( + { + source => 'Illcomment', + value => { + illrequest_id => $illrq_obj->illrequest_id, + borrowernumber => $librarian->{borrowernumber}, + comment => $comment_text, + } } -}); +); # Get all the comments my $comments = $illrq_obj->illcomments; -isa_ok( $comments, 'Koha::Illcomments', "Illcomments" ); +isa_ok( $comments, 'Koha::ILL::Comments', "Illcomments" ); my @comments_list = $comments->as_list(); is( scalar @comments_list, 1, "We have 1 comment" ); # Get the first (and only) comment my $comment = $comments->next(); -isa_ok( $comment, 'Koha::Illcomment', "Illcomment" ); +isa_ok( $comment, 'Koha::ILL::Comment', "Illcomment" ); # Check the different data in the comment is( $comment->illrequest_id, $illrq_obj->illrequest_id, 'illrequest_id getter works' ); -is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works'); -is( $comment->comment, $comment_text, 'comment getter works'); +is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works' ); +is( $comment->comment, $comment_text, 'comment getter works' ); $illrq_obj->delete; diff --git a/t/db_dependent/api/v1/ill_requests.t b/t/db_dependent/api/v1/ill_requests.t index 3e7bb9d681..7822acc486 100755 --- a/t/db_dependent/api/v1/ill_requests.t +++ b/t/db_dependent/api/v1/ill_requests.t @@ -209,7 +209,7 @@ subtest 'list() tests' => sub { # x-koha-embed: comments # Create comment my $comment_text = "This is the comment"; - my $comment = $builder->build_object({ class => 'Koha::Illcomments', value => { illrequest_id => $req_1->illrequest_id, comment => $comment_text , borrowernumber => $patron->borrowernumber } } ); + my $comment = $builder->build_object({ class => 'Koha::ILL::Comments', value => { illrequest_id => $req_1->illrequest_id, comment => $comment_text , borrowernumber => $patron->borrowernumber } } ); # Make sure comments come back $t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "comments"} ) -- 2.39.5