From b190c5b0587429e1e41fc2d01e015eb1b5675914 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 14 Dec 2023 15:08:20 +0000 Subject: [PATCH] Bug 35581: Illbatchstatus* -> ILL::Batch::Status* Koha/IllbatchStatus.pm -> Koha/ILL/Batch/Status.pm Koha/IllbatchStatuses.pm -> Koha/ILL/Batch/Statuses.pm Koha/REST/V1/IllbatchStatuses.pm -> Koha/REST/V1/ILL/Batch/Statuses.pm Signed-off-by: David Nind Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- Koha/ILL/Batch.pm | 4 +- .../Batch/Status.pm} | 8 ++-- .../Batch/Statuses.pm} | 10 ++--- .../Batch/Statuses.pm} | 16 ++++---- Koha/REST/V1/ILL/Batches.pm | 2 +- Koha/Schema/Result/IllbatchStatus.pm | 4 +- admin/ill_batch_statuses.pl | 10 ++--- api/v1/swagger/paths/ill_batchstatuses.yaml | 10 ++--- .../ILL/Batch/Statuses.t} | 40 +++++++++---------- t/db_dependent/api/v1/ill_batches.t | 6 +-- t/db_dependent/api/v1/ill_batchstatuses.t | 20 +++++----- 11 files changed, 65 insertions(+), 65 deletions(-) rename Koha/{IllbatchStatus.pm => ILL/Batch/Status.pm} (93%) rename Koha/{IllbatchStatuses.pm => ILL/Batch/Statuses.pm} (83%) rename Koha/REST/V1/{IllbatchStatuses.pm => ILL/Batch/Statuses.pm} (85%) rename t/db_dependent/{IllbatchStatuses.t => Koha/ILL/Batch/Statuses.t} (81%) diff --git a/Koha/ILL/Batch.pm b/Koha/ILL/Batch.pm index cce981bc8c..d5aa7955fe 100644 --- a/Koha/ILL/Batch.pm +++ b/Koha/ILL/Batch.pm @@ -23,7 +23,7 @@ use Koha::Database; use Koha::Illrequests; use Koha::Illrequest::Logger; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Statuses; use Koha::Libraries; use Koha::Patrons; @@ -46,7 +46,7 @@ Return the status object associated with this batch sub status { my ($self) = @_; - return Koha::IllbatchStatus->_new_from_dbic( scalar $self->_result->status_code ); + return Koha::ILL::Batch::Status->_new_from_dbic( scalar $self->_result->status_code ); } =head3 patron diff --git a/Koha/IllbatchStatus.pm b/Koha/ILL/Batch/Status.pm similarity index 93% rename from Koha/IllbatchStatus.pm rename to Koha/ILL/Batch/Status.pm index b5c26c72f4..6f49f618c4 100644 --- a/Koha/IllbatchStatus.pm +++ b/Koha/ILL/Batch/Status.pm @@ -1,4 +1,4 @@ -package Koha::IllbatchStatus; +package Koha::ILL::Batch::Status; # Copyright PTFS Europe 2022 # @@ -26,7 +26,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::IllbatchStatus - Koha IllbatchStatus Object class +Koha::ILL::Batch::Status - Koha IllbatchStatus Object class =head2 Class methods @@ -46,7 +46,7 @@ sub create_and_log { $fixed_code =~ s/\W/_/; # Ensure this status doesn't already exist - my $status = Koha::IllbatchStatuses->find( { code => $fixed_code } ); + my $status = Koha::ILL::Batch::Statuses->find( { code => $fixed_code } ); if ($status) { return { error => "Duplicate status found" }; } @@ -145,7 +145,7 @@ sub delete_and_log { =head3 _type - my $type = Koha::IllbatchStatus->_type; + my $type = Koha::ILL::Batch::Statuses->_type; Return this object's type diff --git a/Koha/IllbatchStatuses.pm b/Koha/ILL/Batch/Statuses.pm similarity index 83% rename from Koha/IllbatchStatuses.pm rename to Koha/ILL/Batch/Statuses.pm index 1cbeedbd03..de28239020 100644 --- a/Koha/IllbatchStatuses.pm +++ b/Koha/ILL/Batch/Statuses.pm @@ -1,4 +1,4 @@ -package Koha::IllbatchStatuses; +package Koha::ILL::Batch::Statuses; # Copyright PTFS Europe 2022 # @@ -19,18 +19,18 @@ package Koha::IllbatchStatuses; use Modern::Perl; use Koha::Database; -use Koha::IllbatchStatus; +use Koha::ILL::Batch::Status; use base qw(Koha::Objects); =head1 NAME -Koha::IllbatchStatuses - Koha IllbatchStatuses Object class +Koha::ILL::Batch::Statuses - Koha IllbatchStatuses Object class =head2 Internal methods =head3 _type - my $type = Koha::IllbatchStatuses->_type; + my $type = Koha::ILL::Batch::Statuses->_type; Return this object's type @@ -49,7 +49,7 @@ Return this object's class name =cut sub object_class { - return 'Koha::IllbatchStatus'; + return 'Koha::ILL::Batch::Status'; } =head1 AUTHOR diff --git a/Koha/REST/V1/IllbatchStatuses.pm b/Koha/REST/V1/ILL/Batch/Statuses.pm similarity index 85% rename from Koha/REST/V1/IllbatchStatuses.pm rename to Koha/REST/V1/ILL/Batch/Statuses.pm index 1527dd3875..274b525861 100644 --- a/Koha/REST/V1/IllbatchStatuses.pm +++ b/Koha/REST/V1/ILL/Batch/Statuses.pm @@ -1,4 +1,4 @@ -package Koha::REST::V1::IllbatchStatuses; +package Koha::REST::V1::ILL::Batch::Statuses; # This file is part of Koha. # @@ -19,11 +19,11 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Statuses; =head1 NAME -Koha::REST::V1::IllbatchStatuses +Koha::REST::V1::ILL::Batch::Statuses =head2 Operations @@ -36,7 +36,7 @@ Return a list of available ILL batch statuses sub list { my $c = shift->openapi->valid_input; - my @statuses = Koha::IllbatchStatuses->search()->as_list; + my @statuses = Koha::ILL::Batch::Statuses->search()->as_list; return $c->render( status => 200, openapi => \@statuses ); } @@ -52,7 +52,7 @@ sub get { my $status_code = $c->param('ill_batchstatus_code'); - my $status = Koha::IllbatchStatuses->find( { code => $status_code } ); + my $status = Koha::ILL::Batch::Statuses->find( { code => $status_code } ); if ( not defined $status ) { return $c->render( @@ -78,7 +78,7 @@ sub add { my $body = $c->req->json; - my $status = Koha::IllbatchStatus->new($body); + my $status = Koha::ILL::Batch::Status->new($body); return try { my $return = $status->create_and_log; @@ -107,7 +107,7 @@ Update a batch status sub update { my $c = shift->openapi->valid_input or return; - my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } ); + my $status = Koha::ILL::Batch::Statuses->find( { code => $c->param('ill_batchstatus_code') } ); if ( not defined $status ) { return $c->render( @@ -142,7 +142,7 @@ sub delete { my $c = shift->openapi->valid_input or return; - my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } ); + my $status = Koha::ILL::Batch::Statuses->find( { code => $c->param('ill_batchstatus_code') } ); if ( not defined $status ) { return $c->render( status => 404, openapi => { errors => [ { message => "ILL batch status not found" } ] } ); diff --git a/Koha/REST/V1/ILL/Batches.pm b/Koha/REST/V1/ILL/Batches.pm index 0f932e3622..ab79e0d483 100644 --- a/Koha/REST/V1/ILL/Batches.pm +++ b/Koha/REST/V1/ILL/Batches.pm @@ -20,7 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::ILL::Batches; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Statuses; use Koha::Illrequests; use Try::Tiny qw( catch try ); diff --git a/Koha/Schema/Result/IllbatchStatus.pm b/Koha/Schema/Result/IllbatchStatus.pm index f0b9e983ca..c04a576181 100644 --- a/Koha/Schema/Result/IllbatchStatus.pm +++ b/Koha/Schema/Result/IllbatchStatus.pm @@ -119,11 +119,11 @@ __PACKAGE__->add_columns( ); sub koha_object_class { - 'Koha::IllbatchStatus'; + 'Koha::ILL::Batch::Status'; } sub koha_objects_class { - 'Koha::IllbatchStatuses'; + 'Koha::ILL::Batch::Statuses'; } 1; diff --git a/admin/ill_batch_statuses.pl b/admin/ill_batch_statuses.pl index b46b5d0a13..3a63c12a67 100755 --- a/admin/ill_batch_statuses.pl +++ b/admin/ill_batch_statuses.pl @@ -25,8 +25,8 @@ use C4::Context; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use Koha::IllbatchStatus; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Status; +use Koha::ILL::Batch::Statuses; my $input = CGI->new; my $code = $input->param('code'); @@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $status; if ($code) { - $status = Koha::IllbatchStatuses->find( { code => $code } ); + $status = Koha::ILL::Batch::Statuses->find( { code => $code } ); } if ( $op eq 'add_form' ) { @@ -56,7 +56,7 @@ if ( $op eq 'add_form' ) { my $code = $input->param('code'); if ( not defined $status ) { - $status = Koha::IllbatchStatus->new( + $status = Koha::ILL::Batch::Status->new( { name => $name, code => $code @@ -86,7 +86,7 @@ if ( $op eq 'add_form' ) { $op = 'list'; } if ( $op eq 'list' ) { - my $statuses = Koha::IllbatchStatuses->search(); + my $statuses = Koha::ILL::Batch::Statuses->search(); $template->param( statuses => $statuses ); } diff --git a/api/v1/swagger/paths/ill_batchstatuses.yaml b/api/v1/swagger/paths/ill_batchstatuses.yaml index 235a5600b2..87aabdd536 100644 --- a/api/v1/swagger/paths/ill_batchstatuses.yaml +++ b/api/v1/swagger/paths/ill_batchstatuses.yaml @@ -1,7 +1,7 @@ --- /ill/batchstatuses: get: - x-mojo-to: IllbatchStatuses#list + x-mojo-to: ILL::Batch::Statuses#list operationId: listIllbatchstatuses tags: - ill_batchstatuses @@ -41,7 +41,7 @@ permissions: ill: "1" post: - x-mojo-to: IllbatchStatuses#add + x-mojo-to: ILL::Batch::Statuses#add operationId: addIllbatchstatus tags: - ill_batchstatuses @@ -92,7 +92,7 @@ ill: "1" "/ill/batchstatuses/{ill_batchstatus_code}": get: - x-mojo-to: IllbatchStatuses#get + x-mojo-to: ILL::Batch::Statuses#get operationId: getIllbatchstatuses tags: - ill_batchstatuses @@ -137,7 +137,7 @@ permissions: ill: "1" put: - x-mojo-to: IllbatchStatuses#update + x-mojo-to: ILL::Batch::Statuses#update operationId: updateIllBatchstatus tags: - ill_batchstatuses @@ -190,7 +190,7 @@ permissions: ill: "1" delete: - x-mojo-to: IllbatchStatuses#delete + x-mojo-to: ILL::Batch::Statuses#delete operationId: deleteBatchstatus tags: - ill_batchstatuses diff --git a/t/db_dependent/IllbatchStatuses.t b/t/db_dependent/Koha/ILL/Batch/Statuses.t similarity index 81% rename from t/db_dependent/IllbatchStatuses.t rename to t/db_dependent/Koha/ILL/Batch/Statuses.t index e256363516..987c1c9e24 100755 --- a/t/db_dependent/IllbatchStatuses.t +++ b/t/db_dependent/Koha/ILL/Batch/Statuses.t @@ -19,8 +19,8 @@ use Modern::Perl; use File::Basename qw/basename/; use Koha::Database; -use Koha::IllbatchStatus; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Status; +use Koha::ILL::Batch::Statuses; use Koha::Patrons; use Koha::Libraries; use t::lib::Mocks; @@ -32,12 +32,12 @@ use Test::More tests => 13; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -use_ok('Koha::IllbatchStatus'); -use_ok('Koha::IllbatchStatuses'); +use_ok('Koha::ILL::Batch::Status'); +use_ok('Koha::ILL::Batch::Statuses'); $schema->storage->txn_begin; -Koha::IllbatchStatuses->search->delete; +Koha::ILL::Batch::Statuses->search->delete; # Keep track of whether our CRUD logging side-effects are happening my $effects = { @@ -68,18 +68,18 @@ my $status = $builder->build( } ); -my $status_obj = Koha::IllbatchStatuses->find( { code => $status->{code} } ); -isa_ok( $status_obj, 'Koha::IllbatchStatus' ); +my $status_obj = Koha::ILL::Batch::Statuses->find( { code => $status->{code} } ); +isa_ok( $status_obj, 'Koha::ILL::Batch::Status' ); # Try to delete the status, it's a system status, so this should fail $status_obj->delete_and_log; -my $status_obj_del = Koha::IllbatchStatuses->find( { code => $status->{code} } ); -isa_ok( $status_obj_del, 'Koha::IllbatchStatus' ); +my $status_obj_del = Koha::ILL::Batch::Statuses->find( { code => $status->{code} } ); +isa_ok( $status_obj_del, 'Koha::ILL::Batch::Status' ); ## Status create # Try creating a duplicate status -my $status2 = Koha::IllbatchStatus->new( +my $status2 = Koha::ILL::Batch::Status->new( { name => "Obi-wan", code => $status->{code}, @@ -93,7 +93,7 @@ is_deeply( ); # Create a non-duplicate status and ensure that the logger is called -my $status3 = Koha::IllbatchStatus->new( +my $status3 = Koha::ILL::Batch::Status->new( { name => "Kylo", code => "DARK_SIDE", @@ -108,7 +108,7 @@ is( ); # Try creating a system status and ensure it's not created -my $cannot_create_system = Koha::IllbatchStatus->new( +my $cannot_create_system = Koha::ILL::Batch::Status->new( { name => "Jar Jar Binks", code => "GUNGAN", @@ -116,7 +116,7 @@ my $cannot_create_system = Koha::IllbatchStatus->new( } ); $cannot_create_system->create_and_log; -my $created_but_not_system = Koha::IllbatchStatuses->find( { code => "GUNGAN" } ); +my $created_but_not_system = Koha::ILL::Batch::Statuses->find( { code => "GUNGAN" } ); is( $created_but_not_system->{is_system}, undef, "is_system statuses cannot be created" ); ## Status update @@ -131,7 +131,7 @@ $status3->update_and_log( ); # Get our updated status, if we can get it by it's code, we know that hasn't changed -my $not_updated = Koha::IllbatchStatuses->find( { code => "DARK_SIDE" } )->unblessed; +my $not_updated = Koha::ILL::Batch::Statuses->find( { code => "DARK_SIDE" } )->unblessed; is( $not_updated->{is_system}, 0, "is_system cannot be changed" ); is( $not_updated->{name}, "Rey", "name can be changed" ); @@ -143,14 +143,14 @@ is( ); ## Status delete -my $cannot_delete = Koha::IllbatchStatus->new( +my $cannot_delete = Koha::ILL::Batch::Status->new( { name => "Palapatine", code => "SITH", is_system => 1 } )->store; -my $can_delete = Koha::IllbatchStatus->new( +my $can_delete = Koha::ILL::Batch::Status->new( { name => "Windu", code => "JEDI", @@ -158,8 +158,8 @@ my $can_delete = Koha::IllbatchStatus->new( } ); $cannot_delete->delete_and_log; -my $not_deleted = Koha::IllbatchStatuses->find( { code => "SITH" } ); -isa_ok( $not_deleted, 'Koha::IllbatchStatus', "is_system statuses cannot be deleted" ); +my $not_deleted = Koha::ILL::Batch::Statuses->find( { code => "SITH" } ); +isa_ok( $not_deleted, 'Koha::ILL::Batch::Status', "is_system statuses cannot be deleted" ); $can_delete->create_and_log; $can_delete->delete_and_log; @@ -171,7 +171,7 @@ is( ); # Create a system "UNKNOWN" status -my $status_unknown = Koha::IllbatchStatus->new( +my $status_unknown = Koha::ILL::Batch::Status->new( { name => "Unknown", code => "UNKNOWN", @@ -183,7 +183,7 @@ $status_unknown->create_and_log; # Create a batch and assign it a status my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $library = $builder->build_object( { class => 'Koha::Libraries' } ); -my $status5 = Koha::IllbatchStatus->new( +my $status5 = Koha::ILL::Batch::Status->new( { name => "Plagueis", code => "DEAD_SITH", diff --git a/t/db_dependent/api/v1/ill_batches.t b/t/db_dependent/api/v1/ill_batches.t index bc8e2a514d..3dda9cc467 100755 --- a/t/db_dependent/api/v1/ill_batches.t +++ b/t/db_dependent/api/v1/ill_batches.t @@ -28,7 +28,7 @@ use JSON qw(encode_json); use Koha::ILL::Batch; use Koha::ILL::Batches; use Koha::Illrequests; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Statuses; use Koha::Database; my $schema = Koha::Database->new->schema; @@ -214,7 +214,7 @@ subtest 'add() tests' => sub { my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $batch_status = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); + my $batch_status = $builder->build_object( { class => 'Koha::ILL::Batch::Statuses' } ); my $batch_metadata = { name => "Anakin's requests", @@ -294,7 +294,7 @@ subtest 'update() tests' => sub { $t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batches/$batch_id" => json => { name => 'These are not the droids you are looking for' } )->status_is(403); - my $batch_status = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); + my $batch_status = $builder->build_object( { class => 'Koha::ILL::Batch::Statuses' } ); # Attempt partial update on a PUT my $batch_with_missing_field = { diff --git a/t/db_dependent/api/v1/ill_batchstatuses.t b/t/db_dependent/api/v1/ill_batchstatuses.t index 55354ddcc8..b9af25a075 100755 --- a/t/db_dependent/api/v1/ill_batchstatuses.t +++ b/t/db_dependent/api/v1/ill_batchstatuses.t @@ -23,8 +23,8 @@ use Test::Mojo; use t::lib::TestBuilder; use t::lib::Mocks; -use Koha::IllbatchStatus; -use Koha::IllbatchStatuses; +use Koha::ILL::Batch::Status; +use Koha::ILL::Batch::Statuses; use Koha::Database; my $schema = Koha::Database->new->schema; @@ -39,7 +39,7 @@ subtest 'list() tests' => sub { $schema->storage->txn_begin; - Koha::IllbatchStatuses->search->delete; + Koha::ILL::Batch::Statuses->search->delete; # Create an admin user my $librarian = $builder->build_object( @@ -60,7 +60,7 @@ subtest 'list() tests' => sub { my $status = $builder->build_object( { - class => 'Koha::IllbatchStatuses', + class => 'Koha::ILL::Batch::Statuses', value => { name => "Han Solo", code => "SOLO", @@ -94,7 +94,7 @@ subtest 'get() tests' => sub { my $status = $builder->build_object( { - class => 'Koha::IllbatchStatuses', + class => 'Koha::ILL::Batch::Statuses', value => { name => "Han Solo", code => "SOLO", @@ -119,7 +119,7 @@ subtest 'get() tests' => sub { $t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/" . $status->id )->status_is(403); - my $status_to_delete = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); + my $status_to_delete = $builder->build_object( { class => 'Koha::ILL::Batch::Statuses' } ); my $non_existent_code = $status_to_delete->code; $status_to_delete->delete; @@ -218,7 +218,7 @@ subtest 'update() tests' => sub { $patron->set_password( { password => $password, skip_validation => 1 } ); my $unauth_userid = $patron->userid; - my $status_code = $builder->build_object( { class => 'Koha::IllbatchStatuses' } )->code; + my $status_code = $builder->build_object( { class => 'Koha::ILL::Batch::Statuses' } )->code; # Unauthorized attempt to update $t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => @@ -260,7 +260,7 @@ subtest 'update() tests' => sub { ] ); - my $status_to_delete = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); + my $status_to_delete = $builder->build_object( { class => 'Koha::ILL::Batch::Statuses' } ); my $non_existent_code = $status_to_delete->code; $status_to_delete->delete; @@ -299,14 +299,14 @@ subtest 'delete() tests' => sub { my $non_system_status = $builder->build_object( { - class => 'Koha::IllbatchStatuses', + class => 'Koha::ILL::Batch::Statuses', value => { is_system => 0 } } ); my $system_status = $builder->build_object( { - class => 'Koha::IllbatchStatuses', + class => 'Koha::ILL::Batch::Statuses', value => { is_system => 1 } } ); -- 2.39.5