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 <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2023-12-14 14:41:07 -01:00 committed by Katrin Fischer
parent b190c5b058
commit c766172d50
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
6 changed files with 41 additions and 37 deletions

View File

@ -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

View File

@ -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

View File

@ -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<Koha::Illcomments> resultset for the linked comments.
Returns a I<Koha::ILL::Comments> 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
);
}

View File

@ -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;

View File

@ -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;

View File

@ -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"} )