From a7a2de8bcb8c16d997798c47f2b068027e3d8253 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 18 Mar 2021 02:13:50 +0000 Subject: [PATCH] Bug 17499: (follow-up) Rename to Koha::Patron::MessagePreference Koha::Patron::Message refers to "messages" table that is used for circulation messages. MessagePreference now refers to a messaging preference that is used for enqueued notifications. To test: 1. prove t/db_dependent/Koha/Patron/MessagePreference/Attributes.t 2. prove t/db_dependent/Koha/Patron/MessagePreference/Transport/Preferences.t 3. prove t/db_dependent/Koha/Patron/MessagePreference/Transport/Types.t 4. prove t/db_dependent/Koha/Patron/MessagePreference/Transports.t 5. prove t/db_dependent/Koha/Patron/MessagePreferences.t Sponsored-by: The National Library of Finland Signed-off-by: Michal Denar --- .../Preference.pm => MessagePreference.pm} | 44 ++-- .../Transport.pm | 8 +- Koha/Patron.pm | 12 +- .../Preference.pm => MessagePreference.pm} | 72 +++--- .../Attribute.pm | 4 +- .../Attributes.pm | 8 +- .../Transport.pm | 4 +- .../Transport/Preference.pm | 4 +- .../Transport/Preferences.pm | 8 +- .../Transport/Type.pm | 4 +- .../Transport/Types.pm | 8 +- .../Transports.pm | 8 +- .../Preferences.pm => MessagePreferences.pm} | 26 +- .../Result/BorrowerMessagePreference.pm | 4 +- .../BorrowerMessageTransportPreference.pm | 4 +- Koha/Schema/Result/MessageAttribute.pm | 4 +- Koha/Schema/Result/MessageTransport.pm | 4 +- Koha/Schema/Result/MessageTransportType.pm | 4 +- .../Attributes.t | 18 +- .../Transport/Preferences.t | 36 +-- .../Transport/Types.t | 10 +- .../Transports.t | 18 +- .../Preferences.t => MessagePreferences.t} | 240 +++++++++--------- 23 files changed, 276 insertions(+), 276 deletions(-) rename Koha/Exceptions/Patron/{Message/Preference.pm => MessagePreference.pm} (57%) rename Koha/Exceptions/Patron/{Message => MessagePreference}/Transport.pm (74%) rename Koha/Patron/{Message/Preference.pm => MessagePreference.pm} (84%) rename Koha/Patron/{Message => MessagePreference}/Attribute.pm (86%) rename Koha/Patron/{Message => MessagePreference}/Attributes.pm (80%) rename Koha/Patron/{Message => MessagePreference}/Transport.pm (86%) rename Koha/Patron/{Message => MessagePreference}/Transport/Preference.pm (86%) rename Koha/Patron/{Message => MessagePreference}/Transport/Preferences.pm (78%) rename Koha/Patron/{Message => MessagePreference}/Transport/Type.pm (87%) rename Koha/Patron/{Message => MessagePreference}/Transport/Types.pm (79%) rename Koha/Patron/{Message => MessagePreference}/Transports.pm (80%) rename Koha/Patron/{Message/Preferences.pm => MessagePreferences.pm} (80%) rename t/db_dependent/Koha/Patron/{Message => MessagePreference}/Attributes.t (76%) rename t/db_dependent/Koha/Patron/{Message => MessagePreference}/Transport/Preferences.t (76%) rename t/db_dependent/Koha/Patron/{Message => MessagePreference}/Transport/Types.t (76%) rename t/db_dependent/Koha/Patron/{Message => MessagePreference}/Transports.t (82%) rename t/db_dependent/Koha/Patron/{Message/Preferences.t => MessagePreferences.t} (78%) diff --git a/Koha/Exceptions/Patron/Message/Preference.pm b/Koha/Exceptions/Patron/MessagePreference.pm similarity index 57% rename from Koha/Exceptions/Patron/Message/Preference.pm rename to Koha/Exceptions/Patron/MessagePreference.pm index ddde51e181..02509c2222 100644 --- a/Koha/Exceptions/Patron/Message/Preference.pm +++ b/Koha/Exceptions/Patron/MessagePreference.pm @@ -1,4 +1,4 @@ -package Koha::Exceptions::Patron::Message::Preference; +package Koha::Exceptions::Patron::MessagePreference; # This file is part of Koha. # @@ -19,56 +19,56 @@ use Modern::Perl; use Exception::Class ( - 'Koha::Exceptions::Patron::Message::Preference' => { + 'Koha::Exceptions::Patron::MessagePreference' => { description => 'Something went wrong' }, - 'Koha::Exceptions::Patron::Message::Preference::AttributeNotFound' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::AttributeNotFound' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Message attribute not found", fields => ['message_attribute_id'] }, - 'Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Days in advance is out of range", fields => ['min','max', 'message_name'] }, - 'Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceNotAvailable' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceNotAvailable' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Days in advance cannot be selected for this preference", fields => ['message_name'] }, - 'Koha::Exceptions::Patron::Message::Preference::DigestNotAvailable' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::DigestNotAvailable' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Digest is not available for this message type", fields => ['message_name'] }, - 'Koha::Exceptions::Patron::Message::Preference::DigestRequired' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::DigestRequired' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Digest must be selected for this message type", fields => ['message_name'] }, - 'Koha::Exceptions::Patron::Message::Preference::EmailAddressRequired' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::EmailAddressRequired' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Patron has no email address, cannot use email transport type.", fields => ['message_name', 'borrowernumber' ] }, - 'Koha::Exceptions::Patron::Message::Preference::NoTransportType' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::NoTransportType' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Transport type not available for this message.", fields => ['message_name', 'transport_type'] }, - 'Koha::Exceptions::Patron::Message::Preference::PhoneNumberRequired' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::PhoneNumberRequired' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Patron has no phone number, cannot use phone transport type.", fields => ['message_name', 'borrowernumber' ] }, - 'Koha::Exceptions::Patron::Message::Preference::SMSNumberRequired' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::SMSNumberRequired' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "Patron has no SMS number, cannot use sms transport type.", fields => ['message_name', 'borrowernumber' ] }, - 'Koha::Exceptions::Patron::Message::Preference::TalkingTechItivaPhoneNotificationRequired' => { - isa => 'Koha::Exceptions::Patron::Message::Preference', + 'Koha::Exceptions::Patron::MessagePreference::TalkingTechItivaPhoneNotificationRequired' => { + isa => 'Koha::Exceptions::Patron::MessagePreference', description => "System preference TalkingTechItivaPhoneNotification is disabled, cannot use itiva transport type.", fields => ['message_name', 'borrowernumber' ] }, diff --git a/Koha/Exceptions/Patron/Message/Transport.pm b/Koha/Exceptions/Patron/MessagePreference/Transport.pm similarity index 74% rename from Koha/Exceptions/Patron/Message/Transport.pm rename to Koha/Exceptions/Patron/MessagePreference/Transport.pm index 6a7e00a96e..7f6b61ef5a 100644 --- a/Koha/Exceptions/Patron/Message/Transport.pm +++ b/Koha/Exceptions/Patron/MessagePreference/Transport.pm @@ -1,4 +1,4 @@ -package Koha::Exceptions::Patron::Message::Transport; +package Koha::Exceptions::Patron::MessagePreference::Transport; # This file is part of Koha. # @@ -19,11 +19,11 @@ use Modern::Perl; use Exception::Class ( - 'Koha::Exceptions::Patron::Message::Transport' => { + 'Koha::Exceptions::Patron::MessagePreference::Transport' => { description => 'Something went wrong' }, - 'Koha::Exceptions::Patron::Message::Transport::TypeNotFound' => { - isa => 'Koha::Exceptions::Patron::Message::Transport', + 'Koha::Exceptions::Patron::MessagePreference::Transport::TypeNotFound' => { + isa => 'Koha::Exceptions::Patron::MessagePreference::Transport', description => "Transport type does not exist.", fields => ['transport_type'] }, diff --git a/Koha/Patron.pm b/Koha/Patron.pm index eab7012b61..eef61942de 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -50,7 +50,7 @@ use Koha::Patron::HouseboundRole; use Koha::Patron::Images; use Koha::Patron::Messages; use Koha::Patron::Modifications; -use Koha::Patron::Message::Preferences; +use Koha::Patron::MessagePreferences; use Koha::Patron::Relationships; use Koha::Patrons; use Koha::Plugins; @@ -1910,7 +1910,7 @@ sub get_extended_attribute { Sets default messaging preferences on patron. -See Koha::Patron::Message::Preference(s) for more documentation, especially on +See Koha::Patron::MessagePreference(s) for more documentation, especially on thrown exceptions. =cut @@ -1918,11 +1918,11 @@ thrown exceptions. sub set_default_messaging_preferences { my ($self, $categorycode) = @_; - my $options = Koha::Patron::Message::Preferences->get_options; + my $options = Koha::Patron::MessagePreferences->get_options; foreach my $option (@$options) { # Check that this option has preference configuration for this category - unless (Koha::Patron::Message::Preferences->search({ + unless (Koha::Patron::MessagePreferences->search({ message_attribute_id => $option->{message_attribute_id}, categorycode => $categorycode || $self->categorycode, })->count) { @@ -1930,12 +1930,12 @@ sub set_default_messaging_preferences { } # Delete current setting - Koha::Patron::Message::Preferences->search({ + Koha::Patron::MessagePreferences->search({ borrowernumber => $self->borrowernumber, message_attribute_id => $option->{message_attribute_id}, })->delete; - Koha::Patron::Message::Preference->new_from_default({ + Koha::Patron::MessagePreference->new_from_default({ borrowernumber => $self->borrowernumber, categorycode => $categorycode || $self->categorycode, message_attribute_id => $option->{message_attribute_id}, diff --git a/Koha/Patron/Message/Preference.pm b/Koha/Patron/MessagePreference.pm similarity index 84% rename from Koha/Patron/Message/Preference.pm rename to Koha/Patron/MessagePreference.pm index 4de5bc5725..ceac1f4ea3 100644 --- a/Koha/Patron/Message/Preference.pm +++ b/Koha/Patron/MessagePreference.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Preference; +package Koha::Patron::MessagePreference; # Copyright Koha-Suomi Oy 2016 # @@ -21,22 +21,22 @@ use Modern::Perl; use Koha::Database; use Koha::Exceptions; -use Koha::Exceptions::Patron::Message::Preference; -use Koha::Exceptions::Patron::Message::Transport; +use Koha::Exceptions::Patron::MessagePreference; +use Koha::Exceptions::Patron::MessagePreference::Transport; use Koha::Exceptions::Patron::Category; use Koha::Patron::Categories; -use Koha::Patron::Message::Attributes; -use Koha::Patron::Message::Preferences; -use Koha::Patron::Message::Transport::Preferences; -use Koha::Patron::Message::Transport::Types; -use Koha::Patron::Message::Transports; +use Koha::Patron::MessagePreference::Attributes; +use Koha::Patron::MessagePreferences; +use Koha::Patron::MessagePreference::Transport::Preferences; +use Koha::Patron::MessagePreference::Transport::Types; +use Koha::Patron::MessagePreference::Transports; use Koha::Patrons; use base qw(Koha::Object); =head1 NAME -Koha::Patron::Message::Preference - Koha Patron Message Preference object class +Koha::Patron::MessagePreference - Koha Patron Message Preference object class =head1 API @@ -46,7 +46,7 @@ Koha::Patron::Message::Preference - Koha Patron Message Preference object class =head3 new -my $preference = Koha::Patron::Message::Preference->new({ +my $preference = Koha::Patron::MessagePreference->new({ borrowernumber => 123, #categorycode => 'ABC', message_attribute_id => 4, @@ -89,7 +89,7 @@ sub new { =head3 new_from_default -my $preference = Koha::Patron::Message::Preference->new_from_default({ +my $preference = Koha::Patron::MessagePreference->new_from_default({ borrowernumber => 123, categorycode => 'ABC', # if not given, patron's categorycode will be used message_attribute_id => 1, @@ -124,7 +124,7 @@ sub new_from_default { $params->{'categorycode'} = $patron->categorycode; } - my $default = Koha::Patron::Message::Preferences->find({ + my $default = Koha::Patron::MessagePreferences->find({ categorycode => $params->{'categorycode'}, message_attribute_id => $params->{'message_attribute_id'}, }); @@ -144,12 +144,12 @@ sub new_from_default { # Set default messaging transport types my $default_transport_types = - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $default->{'borrower_message_preference_id'} }); while (my $transport = $default_transport_types->next) { - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $self->borrower_message_preference_id, message_transport_type => $transport->message_transport_type, })->store; @@ -174,7 +174,7 @@ sub message_name { if ($self->{'_message_name'}) { return $self->{'_message_name'}; } - $self->{'_message_name'} = Koha::Patron::Message::Attributes->find({ + $self->{'_message_name'} = Koha::Patron::MessagePreference::Attributes->find({ message_attribute_id => $self->message_attribute_id, })->message_name; return $self->{'_message_name'}; @@ -201,7 +201,7 @@ sub message_transport_types { return $self->{'_message_transport_types'}; } map { - my $transport = Koha::Patron::Message::Transports->find({ + my $transport = Koha::Patron::MessagePreference::Transports->find({ message_attribute_id => $self->message_attribute_id, message_transport_type => $_->message_transport_type, is_digest => $self->wants_digest @@ -217,7 +217,7 @@ sub message_transport_types { $self->{'_message_transport_types'}->{$_->message_transport_type} = $transport ? $transport->letter_code : ' '; } - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $self->borrower_message_preference_id, })->as_list; return $self->{'_message_transport_types'} || {}; @@ -295,12 +295,12 @@ sub store { # store message transport types if (exists $self->{'_message_transport_types'}) { - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $self->borrower_message_preference_id, })->delete; foreach my $type (keys %{$self->{'_message_transport_types'}}) { - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $self->borrower_message_preference_id, message_transport_type => $type, @@ -315,7 +315,7 @@ sub store { Makes a basic validation for object. -Returns Koha::Patron::Message::Preference object, or throws and exception. +Returns Koha::Patron::MessagePreference object, or throws and exception. =cut @@ -344,7 +344,7 @@ sub validate { } if (!$self->in_storage) { - my $previous = Koha::Patron::Message::Preferences->search({ + my $previous = Koha::Patron::MessagePreferences->search({ borrowernumber => $self->borrowernumber, categorycode => $self->categorycode, message_attribute_id => $self->message_attribute_id, @@ -357,11 +357,11 @@ sub validate { } } - my $attr = Koha::Patron::Message::Attributes->find( + my $attr = Koha::Patron::MessagePreference::Attributes->find( $self->message_attribute_id ); unless ($attr) { - Koha::Exceptions::Patron::Message::Preference::AttributeNotFound->throw( + Koha::Exceptions::Patron::MessagePreference::AttributeNotFound->throw( error => 'Message attribute with id '.$self->message_attribute_id .' not found', message_attribute_id => $self->message_attribute_id, @@ -369,14 +369,14 @@ sub validate { } if (defined $self->days_in_advance) { if ($attr && $attr->takes_days == 0) { - Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceNotAvailable->throw( + Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceNotAvailable->throw( error => 'days_in_advance cannot be defined for '. $attr->message_name . '.', message_name => $attr->message_name, ); } elsif ($self->days_in_advance < 0 || $self->days_in_advance > 30) { - Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange->throw( + Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange->throw( error => 'days_in_advance has to be a value between 0-30 for '. $attr->message_name . '.', message_name => $attr->message_name, @@ -386,18 +386,18 @@ sub validate { } } if (defined $self->wants_digest) { - my $transports = Koha::Patron::Message::Transports->search({ + my $transports = Koha::Patron::MessagePreference::Transports->search({ message_attribute_id => $self->message_attribute_id, is_digest => $self->wants_digest ? 1 : 0, }); unless ($transports->count) { if (!$self->wants_digest) { - Koha::Exceptions::Patron::Message::Preference::DigestRequired->throw( + Koha::Exceptions::Patron::MessagePreference::DigestRequired->throw( error => 'Digest must be selected for '.$attr->message_name.'.', message_name => $attr->message_name ); } else { - Koha::Exceptions::Patron::Message::Preference::DigestNotAvailable->throw( + Koha::Exceptions::Patron::MessagePreference::DigestNotAvailable->throw( error => 'Digest cannot be selected for '.$attr->message_name.'.', message_name => $attr->message_name ); @@ -419,12 +419,12 @@ sub _set_message_transport_types { $self->_validate_message_transport_types({ message_transport_types => $types }); foreach my $type (@$types) { unless (exists $self->{'_message_transport_types'}->{$type}) { - my $transport = Koha::Patron::Message::Transports->search({ + my $transport = Koha::Patron::MessagePreference::Transports->search({ message_attribute_id => $self->message_attribute_id, message_transport_type => $type })->next; unless ($transport) { - Koha::Exceptions::Patron::Message::Preference::NoTransportType->throw( + Koha::Exceptions::Patron::MessagePreference::NoTransportType->throw( error => 'No transport configured for '.$self->message_name. " transport type $type.", message_name => $self->message_name, @@ -433,25 +433,25 @@ sub _set_message_transport_types { } if (defined $self->borrowernumber) { if ( ! $self->mtt_deliverable($type) ) { - Koha::Exceptions::Patron::Message::Preference::EmailAddressRequired->throw( + Koha::Exceptions::Patron::MessagePreference::EmailAddressRequired->throw( error => 'Patron has not set email address, '. 'cannot use email as message transport', message_name => $self->message_name, borrowernumber => $self->borrowernumber, ) if $type eq 'email'; - Koha::Exceptions::Patron::Message::Preference::TalkingTechItivaPhoneNotificationRequired->throw( + Koha::Exceptions::Patron::MessagePreference::TalkingTechItivaPhoneNotificationRequired->throw( error => 'System preference TalkingTechItivaPhoneNotification disabled'. 'cannot use itiva as message transport', message_name => $self->message_name, borrowernumber => $self->borrowernumber, ) if $type eq 'itiva'; - Koha::Exceptions::Patron::Message::Preference::PhoneNumberRequired->throw( + Koha::Exceptions::Patron::MessagePreference::PhoneNumberRequired->throw( error => 'Patron has not set phone number'. 'cannot use phone as message transport', message_name => $self->message_name, borrowernumber => $self->borrowernumber, ) if $type eq 'phone'; - Koha::Exceptions::Patron::Message::Preference::SMSNumberRequired->throw( + Koha::Exceptions::Patron::MessagePreference::SMSNumberRequired->throw( error => 'Patron has not set SMS number'. 'cannot use sms as message transport', message_name => $self->message_name, @@ -476,10 +476,10 @@ sub _validate_message_transport_types { my $types = $params->{'message_transport_types'}; foreach my $type (@{$types}) { - unless (Koha::Patron::Message::Transport::Types->find({ + unless (Koha::Patron::MessagePreference::Transport::Types->find({ message_transport_type => $type })) { - Koha::Exceptions::Patron::Message::Transport::TypeNotFound->throw( + Koha::Exceptions::Patron::MessagePreference::Transport::TypeNotFound->throw( error => "Message transport type '$type' does not exist", transport_type => $type, ); diff --git a/Koha/Patron/Message/Attribute.pm b/Koha/Patron/MessagePreference/Attribute.pm similarity index 86% rename from Koha/Patron/Message/Attribute.pm rename to Koha/Patron/MessagePreference/Attribute.pm index cd265460cd..88311f89c0 100644 --- a/Koha/Patron/Message/Attribute.pm +++ b/Koha/Patron/MessagePreference/Attribute.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Attribute; +package Koha::Patron::MessagePreference::Attribute; # Copyright Koha-Suomi Oy 2016 # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Patron::Message::Attribute - Koha Patron Message Attribute object class +Koha::Patron::MessagePreference::Attribute - Koha Patron Message Attribute object class =head1 API diff --git a/Koha/Patron/Message/Attributes.pm b/Koha/Patron/MessagePreference/Attributes.pm similarity index 80% rename from Koha/Patron/Message/Attributes.pm rename to Koha/Patron/MessagePreference/Attributes.pm index c647b1cf9f..ae608d2e4e 100644 --- a/Koha/Patron/Message/Attributes.pm +++ b/Koha/Patron/MessagePreference/Attributes.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Attributes; +package Koha::Patron::MessagePreference::Attributes; # Copyright Koha-Suomi Oy 2016 # @@ -20,13 +20,13 @@ package Koha::Patron::Message::Attributes; use Modern::Perl; use Koha::Database; -use Koha::Patron::Message::Attribute; +use Koha::Patron::MessagePreference::Attribute; use base qw(Koha::Objects); =head1 NAME -Koha::Patron::Message::Attributes - Koha Patron Message Attributes object class +Koha::Patron::MessagePreference::Attributes - Koha Patron Message Attributes object class =head1 API @@ -49,7 +49,7 @@ sub _type { =cut sub object_class { - return 'Koha::Patron::Message::Attribute'; + return 'Koha::Patron::MessagePreference::Attribute'; } =head1 AUTHOR diff --git a/Koha/Patron/Message/Transport.pm b/Koha/Patron/MessagePreference/Transport.pm similarity index 86% rename from Koha/Patron/Message/Transport.pm rename to Koha/Patron/MessagePreference/Transport.pm index e95ba5cc42..a35cced2b2 100644 --- a/Koha/Patron/Message/Transport.pm +++ b/Koha/Patron/MessagePreference/Transport.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transport; +package Koha::Patron::MessagePreference::Transport; # Copyright Koha-Suomi Oy 2016 # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Patron::Message::Transport - Koha Patron Message Transport object class +Koha::Patron::MessagePreference::Transport - Koha Patron Message Transport object class =head1 API diff --git a/Koha/Patron/Message/Transport/Preference.pm b/Koha/Patron/MessagePreference/Transport/Preference.pm similarity index 86% rename from Koha/Patron/Message/Transport/Preference.pm rename to Koha/Patron/MessagePreference/Transport/Preference.pm index f6be044ced..80388bcabd 100644 --- a/Koha/Patron/Message/Transport/Preference.pm +++ b/Koha/Patron/MessagePreference/Transport/Preference.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transport::Preference; +package Koha::Patron::MessagePreference::Transport::Preference; # Copyright Koha-Suomi Oy 2016 # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Patron::Message::Transport::Preference - Koha Patron Message Transport +Koha::Patron::MessagePreference::Transport::Preference - Koha Patron Message Transport Preference object class =head1 API diff --git a/Koha/Patron/Message/Transport/Preferences.pm b/Koha/Patron/MessagePreference/Transport/Preferences.pm similarity index 78% rename from Koha/Patron/Message/Transport/Preferences.pm rename to Koha/Patron/MessagePreference/Transport/Preferences.pm index a68a299bd1..4fada4e303 100644 --- a/Koha/Patron/Message/Transport/Preferences.pm +++ b/Koha/Patron/MessagePreference/Transport/Preferences.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transport::Preferences; +package Koha::Patron::MessagePreference::Transport::Preferences; # Copyright Koha-Suomi Oy 2016 # @@ -20,13 +20,13 @@ package Koha::Patron::Message::Transport::Preferences; use Modern::Perl; use Koha::Database; -use Koha::Patron::Message::Transport::Preference; +use Koha::Patron::MessagePreference::Transport::Preference; use base qw(Koha::Objects); =head1 NAME -Koha::Patron::Message::Transport::Preferences - Koha Patron Message Transport +Koha::Patron::MessagePreference::Transport::Preferences - Koha Patron Message Transport Preferences object class =head1 API @@ -48,7 +48,7 @@ sub _type { =cut sub object_class { - return 'Koha::Patron::Message::Transport::Preference'; + return 'Koha::Patron::MessagePreference::Transport::Preference'; } =head1 AUTHOR diff --git a/Koha/Patron/Message/Transport/Type.pm b/Koha/Patron/MessagePreference/Transport/Type.pm similarity index 87% rename from Koha/Patron/Message/Transport/Type.pm rename to Koha/Patron/MessagePreference/Transport/Type.pm index 0c92758ead..86ae35bfe1 100644 --- a/Koha/Patron/Message/Transport/Type.pm +++ b/Koha/Patron/MessagePreference/Transport/Type.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transport::Type; +package Koha::Patron::MessagePreference::Transport::Type; # Copyright Koha-Suomi Oy 2016 # @@ -25,7 +25,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::Patron::Message::Transport::Type - Koha Patron Message Transport Type +Koha::Patron::MessagePreference::Transport::Type - Koha Patron Message Transport Type object class =head1 API diff --git a/Koha/Patron/Message/Transport/Types.pm b/Koha/Patron/MessagePreference/Transport/Types.pm similarity index 79% rename from Koha/Patron/Message/Transport/Types.pm rename to Koha/Patron/MessagePreference/Transport/Types.pm index 825868e444..dff148bc6c 100644 --- a/Koha/Patron/Message/Transport/Types.pm +++ b/Koha/Patron/MessagePreference/Transport/Types.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transport::Types; +package Koha::Patron::MessagePreference::Transport::Types; # Copyright Koha-Suomi Oy 2016 # @@ -20,13 +20,13 @@ package Koha::Patron::Message::Transport::Types; use Modern::Perl; use Koha::Database; -use Koha::Patron::Message::Transport::Type; +use Koha::Patron::MessagePreference::Transport::Type; use base qw(Koha::Objects); =head1 NAME -Koha::Patron::Message::Transport::Types - Koha Patron Message Transport Types +Koha::Patron::MessagePreference::Transport::Types - Koha Patron Message Transport Types object class =head1 API @@ -50,7 +50,7 @@ sub _type { =cut sub object_class { - return 'Koha::Patron::Message::Transport::Type'; + return 'Koha::Patron::MessagePreference::Transport::Type'; } =head1 AUTHOR diff --git a/Koha/Patron/Message/Transports.pm b/Koha/Patron/MessagePreference/Transports.pm similarity index 80% rename from Koha/Patron/Message/Transports.pm rename to Koha/Patron/MessagePreference/Transports.pm index 8c5dd57cec..75578c0a12 100644 --- a/Koha/Patron/Message/Transports.pm +++ b/Koha/Patron/MessagePreference/Transports.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Transports; +package Koha::Patron::MessagePreference::Transports; # Copyright Koha-Suomi Oy 2016 # @@ -20,13 +20,13 @@ package Koha::Patron::Message::Transports; use Modern::Perl; use Koha::Database; -use Koha::Patron::Message::Transport; +use Koha::Patron::MessagePreference::Transport; use base qw(Koha::Objects); =head1 NAME -Koha::Patron::Message::Transports - Koha Patron Message Transports object class +Koha::Patron::MessagePreference::Transports - Koha Patron Message Transports object class =head1 API @@ -49,7 +49,7 @@ sub _type { =cut sub object_class { - return 'Koha::Patron::Message::Transport'; + return 'Koha::Patron::MessagePreference::Transport'; } =head1 AUTHOR diff --git a/Koha/Patron/Message/Preferences.pm b/Koha/Patron/MessagePreferences.pm similarity index 80% rename from Koha/Patron/Message/Preferences.pm rename to Koha/Patron/MessagePreferences.pm index cfb7825798..c13e096cc7 100644 --- a/Koha/Patron/Message/Preferences.pm +++ b/Koha/Patron/MessagePreferences.pm @@ -1,4 +1,4 @@ -package Koha::Patron::Message::Preferences; +package Koha::Patron::MessagePreferences; # Copyright Koha-Suomi Oy 2016 # @@ -20,15 +20,15 @@ package Koha::Patron::Message::Preferences; use Modern::Perl; use Koha::Database; -use Koha::Patron::Message::Attributes; -use Koha::Patron::Message::Preference; -use Koha::Patron::Message::Transports; +use Koha::Patron::MessagePreference::Attributes; +use Koha::Patron::MessagePreference; +use Koha::Patron::MessagePreference::Transports; use base qw(Koha::Objects); =head1 NAME -Koha::Patron::Message::Preferences - Koha Patron Message Preferences object class +Koha::Patron::MessagePreferences - Koha Patron Message Preferences object class =head1 API @@ -38,7 +38,7 @@ Koha::Patron::Message::Preferences - Koha Patron Message Preferences object clas =head3 find_with_message_name -Koha::Patron::Message::Preferences->find_with_message_name({ +Koha::Patron::MessagePreferences->find_with_message_name({ borrowernumber => 123, message_name => 'Hold_Filled', }); @@ -51,7 +51,7 @@ sub find_with_message_name { my ($self, $id) = @_; if (ref($id) eq "HASH" && $id->{'message_name'}) { - my $attr = Koha::Patron::Message::Attributes->find({ + my $attr = Koha::Patron::MessagePreference::Attributes->find({ message_name => $id->{'message_name'}, }); $id->{'message_attribute_id'} = ($attr) ? @@ -64,7 +64,7 @@ sub find_with_message_name { =head3 get_options -my $messaging_options = Koha::Patron::Message::Preferences->get_options +my $messaging_options = Koha::Patron::MessagePreferences->get_options Returns an ARRAYref of HASHrefs on available messaging options. @@ -73,7 +73,7 @@ Returns an ARRAYref of HASHrefs on available messaging options. sub get_options { my ($self) = @_; - my $transports = Koha::Patron::Message::Transports->search(undef, + my $transports = Koha::Patron::MessagePreference::Transports->search(undef, { join => ['message_attribute'], '+select' => ['message_attribute.message_name', 'message_attribute.takes_days'], @@ -99,13 +99,13 @@ sub get_options { =head3 search_with_message_name -Koha::Patron::Message::Preferences->search_with_message_name({ +Koha::Patron::MessagePreferences->search_with_message_name({ borrowernumber => 123, message_name => 'Hold_Filled', }); Converts C into C and continues search. Use -Koha::Patron::Message::Preferences->search with a proper join for more complicated +Koha::Patron::MessagePreferences->search with a proper join for more complicated searches. =cut @@ -114,7 +114,7 @@ sub search_with_message_name { my ($self, $params, $attributes) = @_; if (ref($params) eq "HASH" && $params->{'message_name'}) { - my $attr = Koha::Patron::Message::Attributes->find({ + my $attr = Koha::Patron::MessagePreference::Attributes->find({ message_name => $params->{'message_name'}, }); $params->{'message_attribute_id'} = ($attr) ? @@ -138,7 +138,7 @@ sub _type { =cut sub object_class { - return 'Koha::Patron::Message::Preference'; + return 'Koha::Patron::MessagePreference'; } =head1 AUTHOR diff --git a/Koha/Schema/Result/BorrowerMessagePreference.pm b/Koha/Schema/Result/BorrowerMessagePreference.pm index 34f21f9e12..cc2ba920ec 100644 --- a/Koha/Schema/Result/BorrowerMessagePreference.pm +++ b/Koha/Schema/Result/BorrowerMessagePreference.pm @@ -196,10 +196,10 @@ __PACKAGE__->many_to_many( # You can replace this text with custom content, and it will be preserved on regeneration sub koha_object_class { - 'Koha::Patron::Message::Preference'; + 'Koha::Patron::MessagePreference'; } sub koha_objects_class { - 'Koha::Patron::Message::Preferences'; + 'Koha::Patron::MessagePreferences'; } 1; diff --git a/Koha/Schema/Result/BorrowerMessageTransportPreference.pm b/Koha/Schema/Result/BorrowerMessageTransportPreference.pm index be3751c6da..c13a760a7d 100644 --- a/Koha/Schema/Result/BorrowerMessageTransportPreference.pm +++ b/Koha/Schema/Result/BorrowerMessageTransportPreference.pm @@ -114,10 +114,10 @@ __PACKAGE__->belongs_to( # You can replace this text with custom content, and it will be preserved on regeneration sub koha_object_class { - 'Koha::Patron::Message::Transport::Preference'; + 'Koha::Patron::MessagePreference::Transport::Preference'; } sub koha_objects_class { - 'Koha::Patron::Message::Transport::Preferences'; + 'Koha::Patron::MessagePreference::Transport::Preferences'; } 1; diff --git a/Koha/Schema/Result/MessageAttribute.pm b/Koha/Schema/Result/MessageAttribute.pm index e1357ac2b2..0e3f426591 100644 --- a/Koha/Schema/Result/MessageAttribute.pm +++ b/Koha/Schema/Result/MessageAttribute.pm @@ -119,10 +119,10 @@ __PACKAGE__->has_many( # You can replace this text with custom content, and it will be preserved on regeneration sub koha_object_class { - 'Koha::Patron::Message::Attribute'; + 'Koha::Patron::MessagePreference::Attribute'; } sub koha_objects_class { - 'Koha::Patron::Message::Attributes'; + 'Koha::Patron::MessagePreference::Attributes'; } 1; diff --git a/Koha/Schema/Result/MessageTransport.pm b/Koha/Schema/Result/MessageTransport.pm index ee7bc79450..8a9559c4b5 100644 --- a/Koha/Schema/Result/MessageTransport.pm +++ b/Koha/Schema/Result/MessageTransport.pm @@ -136,10 +136,10 @@ __PACKAGE__->belongs_to( # You can replace this text with custom content, and it will be preserved on regeneration sub koha_object_class { - 'Koha::Patron::Message::Transport'; + 'Koha::Patron::MessagePreference::Transport'; } sub koha_objects_class { - 'Koha::Patron::Message::Transports'; + 'Koha::Patron::MessagePreference::Transports'; } 1; diff --git a/Koha/Schema/Result/MessageTransportType.pm b/Koha/Schema/Result/MessageTransportType.pm index 060336977f..34dd3de4a7 100644 --- a/Koha/Schema/Result/MessageTransportType.pm +++ b/Koha/Schema/Result/MessageTransportType.pm @@ -157,10 +157,10 @@ __PACKAGE__->many_to_many( # You can replace this text with custom content, and it will be preserved on regeneration sub koha_object_class { - 'Koha::Patron::Message::Transport::Type'; + 'Koha::Patron::MessagePreference::Transport::Type'; } sub koha_objects_class { - 'Koha::Patron::Message::Transport::Types'; + 'Koha::Patron::MessagePreference::Transport::Types'; } 1; diff --git a/t/db_dependent/Koha/Patron/Message/Attributes.t b/t/db_dependent/Koha/Patron/MessagePreference/Attributes.t similarity index 76% rename from t/db_dependent/Koha/Patron/Message/Attributes.t rename to t/db_dependent/Koha/Patron/MessagePreference/Attributes.t index 836b4f0cd5..2c882578fc 100644 --- a/t/db_dependent/Koha/Patron/Message/Attributes.t +++ b/t/db_dependent/Koha/Patron/MessagePreference/Attributes.t @@ -28,26 +28,26 @@ my $schema = Koha::Database->new->schema; subtest 'Test class imports' => sub { plan tests => 2; - use_ok('Koha::Patron::Message::Attribute'); - use_ok('Koha::Patron::Message::Attributes'); + use_ok('Koha::Patron::MessagePreference::Attribute'); + use_ok('Koha::Patron::MessagePreference::Attributes'); }; -subtest 'Test Koha::Patron::Message::Attributes' => sub { +subtest 'Test Koha::Patron::MessagePreference::Attributes' => sub { plan tests => 6; $schema->storage->txn_begin; - Koha::Patron::Message::Attribute->new({ + Koha::Patron::MessagePreference::Attribute->new({ message_name => 'Test_Attribute' })->store; - Koha::Patron::Message::Attribute->new({ + Koha::Patron::MessagePreference::Attribute->new({ message_name => 'Test_Attribute2', takes_days => 1 })->store; - my $attribute = Koha::Patron::Message::Attributes->find({ + my $attribute = Koha::Patron::MessagePreference::Attributes->find({ message_name => 'Test_Attribute' }); - my $attribute2 = Koha::Patron::Message::Attributes->find({ + my $attribute2 = Koha::Patron::MessagePreference::Attributes->find({ message_name => 'Test_Attribute2' }); is($attribute->message_name, 'Test_Attribute', @@ -61,10 +61,10 @@ subtest 'Test Koha::Patron::Message::Attributes' => sub { $attribute->delete; $attribute2->delete; - is(Koha::Patron::Message::Attributes->find({ + is(Koha::Patron::MessagePreference::Attributes->find({ message_name => 'Test_Attribute' }), undef, 'Deleted the first message attribute.'); - is(Koha::Patron::Message::Attributes->find({ + is(Koha::Patron::MessagePreference::Attributes->find({ message_name => 'Test_Attribute2' }), undef, 'Deleted the second message attribute.'); diff --git a/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t b/t/db_dependent/Koha/Patron/MessagePreference/Transport/Preferences.t similarity index 76% rename from t/db_dependent/Koha/Patron/Message/Transport/Preferences.t rename to t/db_dependent/Koha/Patron/MessagePreference/Transport/Preferences.t index 3e6c8a8876..f240a6bdd6 100644 --- a/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t +++ b/t/db_dependent/Koha/Patron/MessagePreference/Transport/Preferences.t @@ -26,10 +26,10 @@ use t::lib::TestBuilder; use Koha::Notice::Templates; use Koha::Patron::Categories; -use Koha::Patron::Message::Attributes; -use Koha::Patron::Message::Preferences; -use Koha::Patron::Message::Transport::Types; -use Koha::Patron::Message::Transports; +use Koha::Patron::MessagePreference::Attributes; +use Koha::Patron::MessagePreferences; +use Koha::Patron::MessagePreference::Transport::Types; +use Koha::Patron::MessagePreference::Transports; use Koha::Patrons; my $schema = Koha::Database->new->schema; @@ -38,21 +38,21 @@ my $builder = t::lib::TestBuilder->new; subtest 'Test class imports' => sub { plan tests => 2; - use_ok('Koha::Patron::Message::Transport::Preference'); - use_ok('Koha::Patron::Message::Transport::Preferences'); + use_ok('Koha::Patron::MessagePreference::Transport::Preference'); + use_ok('Koha::Patron::MessagePreference::Transport::Preferences'); }; -subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { +subtest 'Test Koha::Patron::MessagePreference::Transport::Preferences' => sub { plan tests => 2; $schema->storage->txn_begin; - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); - my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); + my $mtt = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); my $letter = build_a_test_letter({ mtt => $mtt->message_transport_type }); - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0, @@ -62,7 +62,7 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { subtest 'For a patron' => sub { my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - my $preference = Koha::Patron::Message::Preference->new({ + my $preference = Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, @@ -70,15 +70,15 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { })->store; my $pref_id = $preference->borrower_message_preference_id; - my $transport_pref = Koha::Patron::Message::Transport::Preference->new({ + my $transport_pref = Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $pref_id, message_transport_type => $mtt->message_transport_type, })->store; - is(ref($transport_pref), 'Koha::Patron::Message::Transport::Preference', + is(ref($transport_pref), 'Koha::Patron::MessagePreference::Transport::Preference', 'Added a new messaging transport preference for patron.'); $transport_pref->delete; - is(Koha::Patron::Message::Transport::Preferences->search({ + is(Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $pref_id, message_transport_type => $mtt->message_transport_type, })->count, 0, 'Deleted the messaging transport preference.'); @@ -86,7 +86,7 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { subtest 'For a category' => sub { my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); - my $preference = Koha::Patron::Message::Preference->new({ + my $preference = Koha::Patron::MessagePreference->new({ categorycode => $category->categorycode, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, @@ -94,15 +94,15 @@ subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { })->store; my $pref_id = $preference->borrower_message_preference_id; - my $transport_pref = Koha::Patron::Message::Transport::Preference->new({ + my $transport_pref = Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $pref_id, message_transport_type => $mtt->message_transport_type, })->store; - is(ref($transport_pref), 'Koha::Patron::Message::Transport::Preference', + is(ref($transport_pref), 'Koha::Patron::MessagePreference::Transport::Preference', 'Added a new messaging transport preference for category.'); $transport_pref->delete; - is(Koha::Patron::Message::Transport::Preferences->search({ + is(Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $pref_id, message_transport_type => $mtt->message_transport_type, })->count, 0, 'Deleted the messaging transport preference.'); diff --git a/t/db_dependent/Koha/Patron/Message/Transport/Types.t b/t/db_dependent/Koha/Patron/MessagePreference/Transport/Types.t similarity index 76% rename from t/db_dependent/Koha/Patron/Message/Transport/Types.t rename to t/db_dependent/Koha/Patron/MessagePreference/Transport/Types.t index cbba32b228..8231fe28e3 100644 --- a/t/db_dependent/Koha/Patron/Message/Transport/Types.t +++ b/t/db_dependent/Koha/Patron/MessagePreference/Transport/Types.t @@ -28,16 +28,16 @@ my $schema = Koha::Database->new->schema; subtest 'Test class imports' => sub { plan tests => 2; - use_ok('Koha::Patron::Message::Transport::Type'); - use_ok('Koha::Patron::Message::Transport::Types'); + use_ok('Koha::Patron::MessagePreference::Transport::Type'); + use_ok('Koha::Patron::MessagePreference::Transport::Types'); }; -subtest 'Test Koha::Patron::Message::Transport::Types' => sub { +subtest 'Test Koha::Patron::MessagePreference::Transport::Types' => sub { plan tests => 2; $schema->storage->txn_begin; - my $transport_type = Koha::Patron::Message::Transport::Type->new({ + my $transport_type = Koha::Patron::MessagePreference::Transport::Type->new({ message_transport_type => 'test' })->store; @@ -45,7 +45,7 @@ subtest 'Test Koha::Patron::Message::Transport::Types' => sub { 'Added a new message transport type.'); $transport_type->delete; - is(Koha::Patron::Message::Transport::Types->find('test'), undef, + is(Koha::Patron::MessagePreference::Transport::Types->find('test'), undef, 'Deleted the message transport type.'); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Patron/Message/Transports.t b/t/db_dependent/Koha/Patron/MessagePreference/Transports.t similarity index 82% rename from t/db_dependent/Koha/Patron/Message/Transports.t rename to t/db_dependent/Koha/Patron/MessagePreference/Transports.t index f6c50a6e0d..000835ecb2 100644 --- a/t/db_dependent/Koha/Patron/Message/Transports.t +++ b/t/db_dependent/Koha/Patron/MessagePreference/Transports.t @@ -24,8 +24,8 @@ use Test::More tests => 2; use t::lib::TestBuilder; use Koha::Notice::Templates; -use Koha::Patron::Message::Attributes; -use Koha::Patron::Message::Transport::Types; +use Koha::Patron::MessagePreference::Attributes; +use Koha::Patron::MessagePreference::Transport::Types; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -33,22 +33,22 @@ my $builder = t::lib::TestBuilder->new; subtest 'Test class imports' => sub { plan tests => 2; - use_ok('Koha::Patron::Message::Transport'); - use_ok('Koha::Patron::Message::Transports'); + use_ok('Koha::Patron::MessagePreference::Transport'); + use_ok('Koha::Patron::MessagePreference::Transports'); }; -subtest 'Test Koha::Patron::Message::Transports' => sub { +subtest 'Test Koha::Patron::MessagePreference::Transports' => sub { plan tests => 2; $schema->storage->txn_begin; - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); - my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); + my $mtt = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); my $letter = build_a_test_letter({ mtt => $mtt->message_transport_type }); - my $transport = Koha::Patron::Message::Transport->new({ + my $transport = Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0, @@ -60,7 +60,7 @@ subtest 'Test Koha::Patron::Message::Transports' => sub { 'Added a new messaging transport.'); $transport->delete; - is(Koha::Patron::Message::Transports->search({ + is(Koha::Patron::MessagePreference::Transports->search({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0 diff --git a/t/db_dependent/Koha/Patron/Message/Preferences.t b/t/db_dependent/Koha/Patron/MessagePreferences.t similarity index 78% rename from t/db_dependent/Koha/Patron/Message/Preferences.t rename to t/db_dependent/Koha/Patron/MessagePreferences.t index a402ae9c3c..9e60cbff2e 100644 --- a/t/db_dependent/Koha/Patron/Message/Preferences.t +++ b/t/db_dependent/Koha/Patron/MessagePreferences.t @@ -28,9 +28,9 @@ use C4::Context; use Koha::Notice::Templates; use Koha::Patron::Categories; -use Koha::Patron::Message::Attributes; -use Koha::Patron::Message::Transport::Types; -use Koha::Patron::Message::Transports; +use Koha::Patron::MessagePreference::Attributes; +use Koha::Patron::MessagePreference::Transport::Types; +use Koha::Patron::MessagePreference::Transports; use Koha::Patrons; use File::Temp qw/tempfile/; @@ -42,19 +42,19 @@ my $builder = t::lib::TestBuilder->new; subtest 'Test class imports' => sub { plan tests => 2; - use_ok('Koha::Patron::Message::Preference'); - use_ok('Koha::Patron::Message::Preferences'); + use_ok('Koha::Patron::MessagePreference'); + use_ok('Koha::Patron::MessagePreferences'); }; -subtest 'Test Koha::Patron::Message::Preferences' => sub { +subtest 'Test Koha::Patron::MessagePreferences' => sub { plan tests => 2; $schema->storage->txn_begin; - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); my $letter = build_a_test_letter(); - my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); - Koha::Patron::Message::Transport->new({ + my $mtt = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0, @@ -66,14 +66,14 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { plan tests => 3; my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, days_in_advance => undef, })->store; - my $preference = Koha::Patron::Message::Preferences->find({ + my $preference = Koha::Patron::MessagePreferences->find({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id }); @@ -83,16 +83,16 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { subtest 'Test set not throwing an exception on duplicate object' => sub { plan tests => 1; - Koha::Patron::Message::Attributes->find({ + Koha::Patron::MessagePreference::Attributes->find({ message_attribute_id => $attribute->message_attribute_id })->set({ takes_days => 1 })->store; $preference->set({ days_in_advance => 1 })->store; - is(ref($preference), 'Koha::Patron::Message::Preference', + is(ref($preference), 'Koha::Patron::MessagePreference', 'Updating the preference does not cause duplicate object exception'); }; $preference->delete; - is(Koha::Patron::Message::Preferences->search({ + is(Koha::Patron::MessagePreferences->search({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id })->count, 0, 'Deleted the messaging preference.'); @@ -100,14 +100,14 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { subtest 'Test for a category' => sub { my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ categorycode => $category->categorycode, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, days_in_advance => undef, })->store; - my $preference = Koha::Patron::Message::Preferences->find({ + my $preference = Koha::Patron::MessagePreferences->find({ categorycode => $category->categorycode, message_attribute_id => $attribute->message_attribute_id }); @@ -115,7 +115,7 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { 'Added a new messaging preference for category.'); $preference->delete; - is(Koha::Patron::Message::Preferences->search({ + is(Koha::Patron::MessagePreferences->search({ categorycode => $category->categorycode, message_attribute_id => $attribute->message_attribute_id })->count, 0, 'Deleted the messaging preference.'); @@ -124,31 +124,31 @@ subtest 'Test Koha::Patron::Message::Preferences' => sub { $schema->storage->txn_rollback; }; -subtest 'Test Koha::Patron::Message::Preferences->get_options' => sub { +subtest 'Test Koha::Patron::MessagePreferences->get_options' => sub { plan tests => 2; subtest 'Test method availability and return value' => sub { plan tests => 3; - ok(Koha::Patron::Message::Preferences->can('get_options'), + ok(Koha::Patron::MessagePreferences->can('get_options'), 'Method get_options is available.'); - ok(my $options = Koha::Patron::Message::Preferences->get_options, + ok(my $options = Koha::Patron::MessagePreferences->get_options, 'Called get_options successfully.'); is(ref($options), 'ARRAY', 'get_options returns a ARRAYref'); }; subtest 'Make sure options are correct' => sub { $schema->storage->txn_begin; - my $options = Koha::Patron::Message::Preferences->get_options; + my $options = Koha::Patron::MessagePreferences->get_options; foreach my $option (@$options) { my $n = $option->{'message_name'}; - my $attr = Koha::Patron::Message::Attributes->find($option->{'message_attribute_id'}); + my $attr = Koha::Patron::MessagePreference::Attributes->find($option->{'message_attribute_id'}); is($option->{'message_attribute_id'}, $attr->message_attribute_id, '$n: message_attribute_id is set'); is($option->{'message_name'}, $attr->message_name, '$n: message_name is set'); is($option->{'takes_days'}, $attr->takes_days, '$n: takes_days is set'); - my $transports = Koha::Patron::Message::Transports->search({ + my $transports = Koha::Patron::MessagePreference::Transports->search({ message_attribute_id => $option->{'message_attribute_id'}, is_digest => $option->{'has_digest'} || 0, }); @@ -171,26 +171,26 @@ subtest 'Add preferences from defaults' => sub { my ($default, $mtt1, $mtt2) = build_a_test_category_preference({ patron => $patron, }); - ok(Koha::Patron::Message::Preference->new_from_default({ + ok(Koha::Patron::MessagePreference->new_from_default({ borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode, message_attribute_id => $default->message_attribute_id, })->store, 'Added a default preference to patron.'); - ok(my $pref = Koha::Patron::Message::Preferences->find({ + ok(my $pref = Koha::Patron::MessagePreferences->find({ borrowernumber => $patron->borrowernumber, message_attribute_id => $default->message_attribute_id, }), 'Found the default preference from patron.'); - is(Koha::Patron::Message::Transport::Preferences->search({ + is(Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $pref->borrower_message_preference_id })->count, 2, 'Found the two transport types that we set earlier'); $schema->storage->txn_rollback; }; -subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub { +subtest 'Test Koha::Patron::MessagePreference->message_transport_types' => sub { plan tests => 4; - ok(Koha::Patron::Message::Preference->can('message_transport_types'), + ok(Koha::Patron::MessagePreference->can('message_transport_types'), 'Method message_transport_types available'); subtest 'get message_transport_types' => sub { @@ -202,25 +202,25 @@ subtest 'Test Koha::Patron::Message::Preference->message_transport_types' => sub my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ patron => $patron }); - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, })->delete; - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $preference->borrower_message_preference_id, message_transport_type => $mtt1->message_transport_type, })->store; - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $preference->borrower_message_preference_id, message_transport_type => $mtt2->message_transport_type, })->store; - my $stored_transports = Koha::Patron::Message::Transport::Preferences->search({ + my $stored_transports = Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, }); - my $transport1 = Koha::Patron::Message::Transports->find({ + my $transport1 = Koha::Patron::MessagePreference::Transports->find({ message_attribute_id => $preference->message_attribute_id, message_transport_type => $mtt1->message_transport_type, }); - my $transport2 = Koha::Patron::Message::Transports->find({ + my $transport2 = Koha::Patron::MessagePreference::Transports->find({ message_attribute_id => $preference->message_attribute_id, message_transport_type => $mtt2->message_transport_type, }); @@ -255,19 +255,19 @@ HERE my $appenders = Log::Log4perl->appenders; my $appender = Log::Log4perl->appenders->{OPAC}; - my $pref = Koha::Patron::Message::Preferences->find( + my $pref = Koha::Patron::MessagePreferences->find( $preference->borrower_message_preference_id ); my $transports = $pref->message_transport_types; is($appender, undef, 'Nothing in buffer yet'); - my $mtt_new = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); - Koha::Patron::Message::Transport::Preference->new({ + my $mtt_new = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $pref->borrower_message_preference_id, message_transport_type => $mtt_new->message_transport_type, })->store; - $pref = Koha::Patron::Message::Preferences->find( + $pref = Koha::Patron::MessagePreferences->find( $pref->borrower_message_preference_id ); $transports = $pref->message_transport_types; @@ -294,12 +294,12 @@ HERE my $mtt1_str = $mtt1->message_transport_type; my $mtt2_str = $mtt2->message_transport_type; # 1/3, use message_transport_types(list) - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, })->delete; ok($preference->message_transport_types($mtt1_str, $mtt2_str)->store, '1/3 Set returned true.'); - my $stored_transports = Koha::Patron::Message::Transport::Preferences->search({ + my $stored_transports = Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, '-or' => [ message_transport_type => $mtt1_str, @@ -309,12 +309,12 @@ HERE is($stored_transports->count, 2, 'Two transports selected'); # 2/3, use message_transport_types(ARRAYREF) - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, })->delete; ok($preference->message_transport_types([$mtt1_str, $mtt2_str])->store, '2/3 Set returned true.'); - $stored_transports = Koha::Patron::Message::Transport::Preferences->search({ + $stored_transports = Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, '-or' => [ message_transport_type => $mtt1_str, @@ -324,13 +324,13 @@ HERE is($stored_transports->count, 2, 'Two transports selected'); # 3/3, use set({ message_transport_types => ARRAYREF }) - Koha::Patron::Message::Transport::Preferences->search({ + Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, })->delete; ok($preference->set({ message_transport_types => [$mtt1_str, $mtt2_str]})->store, '3/3 Set returned true.'); - $stored_transports = Koha::Patron::Message::Transport::Preferences->search({ + $stored_transports = Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, '-or' => [ message_transport_type => $mtt1_str, @@ -340,34 +340,34 @@ HERE is($stored_transports->count, 2, 'Two transports selected'); # Test contact information validation - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'email' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'itiva' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'phone' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'sms' })->store }; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'email', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'itiva', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'phone', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'sms', is_digest => 1 @@ -377,9 +377,9 @@ HERE eval { $preference->message_transport_types('email')->store; }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::EmailAddressRequired', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::EmailAddressRequired', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Preference::EmailAddressRequired'); + .' => Koha::Exceptions::Patron::MessagePreference::EmailAddressRequired'); is ($@->message_name, $preference->message_name, 'The previous exception ' .' tells us it which message name it was.'); is ($@->borrowernumber, $patron->borrowernumber, 'The previous exception ' @@ -387,9 +387,9 @@ HERE eval { $preference->message_transport_types('itiva')->store; }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::TalkingTechItivaPhoneNotificationRequired', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::TalkingTechItivaPhoneNotificationRequired', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Preference::TalkingTechItivaPhoneNotificationRequired'); + .' => Koha::Exceptions::Patron::MessagePreference::TalkingTechItivaPhoneNotificationRequired'); is ($@->message_name, $preference->message_name, 'The previous exception ' .' tells us it which message name it was.'); is ($@->borrowernumber, $patron->borrowernumber, 'The previous exception ' @@ -397,9 +397,9 @@ HERE eval { $preference->message_transport_types('phone')->store; }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::PhoneNumberRequired', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::PhoneNumberRequired', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Preference::PhoneNumberRequired'); + .' => Koha::Exceptions::Patron::MessagePreference::PhoneNumberRequired'); is ($@->message_name, $preference->message_name, 'The previous exception ' .' tells us it which message name it was.'); is ($@->borrowernumber, $patron->borrowernumber, 'The previous exception ' @@ -407,9 +407,9 @@ HERE eval { $preference->message_transport_types('sms')->store; }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::SMSNumberRequired', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::SMSNumberRequired', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Preference::SMSNumberRequired'); + .' => Koha::Exceptions::Patron::MessagePreference::SMSNumberRequired'); is ($@->message_name, $preference->message_name, 'The previous exception ' .' tells us it which message name it was.'); is ($@->borrowernumber, $patron->borrowernumber, 'The previous exception ' @@ -425,16 +425,16 @@ HERE my $patron = $builder->build_object({ class => 'Koha::Patrons' }); my $letter = build_a_test_letter(); - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); - my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); - Koha::Patron::Message::Transport->new({ + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); + my $mtt = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0, letter_module => $letter->module, letter_code => $letter->code, })->store; - ok(my $preference = Koha::Patron::Message::Preference->new({ + ok(my $preference = Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, @@ -443,7 +443,7 @@ HERE })->store, 'Added a new messaging preference and transport types to patron.'); ok($preference->message_transport_types->{$mtt->message_transport_type}, 'The transport type is stored in the object.'); - my $stored_transports = Koha::Patron::Message::Transport::Preferences->search({ + my $stored_transports = Koha::Patron::MessagePreference::Transport::Preferences->search({ borrower_message_preference_id => $preference->borrower_message_preference_id, }); is($stored_transports->next->message_transport_type, $mtt->message_transport_type, @@ -453,18 +453,18 @@ HERE }; }; -subtest 'Test Koha::Patron::Message::Preference->message_name' => sub { +subtest 'Test Koha::Patron::MessagePreference->message_name' => sub { plan tests => 1; $schema->storage->txn_begin; my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); my ($preference, $mtt1, $mtt2) = build_a_test_complete_preference({ patron => $patron, attr => $attribute, }); - my $message_name_pref = Koha::Patron::Message::Preferences->search_with_message_name({ + my $message_name_pref = Koha::Patron::MessagePreferences->search_with_message_name({ borrowernumber => $patron->{'borrowernumber'}, message_name => $attribute->message_name, })->next; @@ -473,7 +473,7 @@ subtest 'Test Koha::Patron::Message::Preference->message_name' => sub { $schema->storage->txn_rollback; }; -subtest 'Test Koha::Patron::Message::Preference->mtt_deliverable' => sub { +subtest 'Test Koha::Patron::MessagePreference->mtt_deliverable' => sub { plan tests => 10; $schema->storage->txn_begin; @@ -484,34 +484,34 @@ subtest 'Test Koha::Patron::Message::Preference->mtt_deliverable' => sub { }); # Test email and smsalertnumber validation - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'email' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'sms' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'phone' })->store }; - eval { Koha::Patron::Message::Transport::Types->new({ + eval { Koha::Patron::MessagePreference::Transport::Types->new({ message_transport_type => 'itiva' })->store }; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'email', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'sms', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'phone', is_digest => 1 })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $preference->message_attribute_id, message_transport_type => 'itiva', is_digest => 1 @@ -557,7 +557,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { subtest 'Missing parameters' => sub { plan tests => 1; - eval { Koha::Patron::Message::Preference->new->store }; + eval { Koha::Patron::MessagePreference->new->store }; is(ref $@, 'Koha::Exceptions::MissingParameter', 'Adding a message preference without parameters' .' => Koha::Exceptions::MissingParameter'); @@ -569,7 +569,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { $schema->storage->txn_begin; my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, categorycode => $patron->categorycode, })->store }; @@ -585,14 +585,14 @@ subtest 'Test adding a new preference with invalid parameters' => sub { $schema->storage->txn_begin; - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => -999, })->store }; is(ref $@, 'Koha::Exceptions::Patron::NotFound', 'Adding a message preference with invalid borrowernumber' .' => Koha::Exceptions::Patron::NotFound'); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ categorycode => 'nonexistent', })->store }; is(ref $@, 'Koha::Exceptions::Patron::Category::NotFound', @@ -601,96 +601,96 @@ subtest 'Test adding a new preference with invalid parameters' => sub { my $attribute = build_a_test_attribute({ takes_days => 0 }); my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, days_in_advance => 10, })->store }; - is(ref $@, 'Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceNotAvailable', + is(ref $@, 'Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceNotAvailable', 'Adding a message preference with days in advance option when not' - .' available => Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceNotAvailable'); + .' available => Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceNotAvailable'); $attribute->set({ takes_days => 1 })->store; - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, days_in_advance => -1, })->store }; - is(ref $@, 'Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange', + is(ref $@, 'Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange', 'Adding a message preference with days in advance option is out of range' - .' => Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange'); + .' => Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange'); is ($@->min, 0, 'The previous exception min value is 0.'); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, days_in_advance => 31, })->store }; - is(ref $@, 'Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange', + is(ref $@, 'Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange', 'Adding a message preference with days in advance option is out of range' - .' => Koha::Exceptions::Patron::Message::Preference::DaysInAdvanceOutOfRange'); + .' => Koha::Exceptions::Patron::MessagePreference::DaysInAdvanceOutOfRange'); is ($@->max, 30, 'The previous exception max value is 30.'); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_transport_types => ['nonexistent'] })->store }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Transport::TypeNotFound', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::Transport::TypeNotFound', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Transport::TypeNotFound'); + .' => Koha::Exceptions::Patron::MessagePreference::Transport::TypeNotFound'); is ($@->transport_type, 'nonexistent', 'The previous exception ' .'tells us it which transport type it was.'); - my $mtt_new = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); + my $mtt_new = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); eval { - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, message_transport_types => [$mtt_new->message_transport_type], wants_digest => 1, })->store }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::NoTransportType', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::NoTransportType', 'Adding a message preference with invalid message_transport_type' - .' => Koha::Exceptions::Patron::Message::Preference::NoTransportType'); + .' => Koha::Exceptions::Patron::MessagePreference::NoTransportType'); is ($@->message_name, $attribute->message_name, 'The previous exception ' .'tells us which message it was.'); is ($@->transport_type, $mtt_new->message_transport_type, 'The previous exception ' .'tells us which message transport type it was.'); eval { - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, message_transport_types => [], wants_digest => 1, })->store }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::DigestNotAvailable', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::DigestNotAvailable', 'Adding a message preference that has no digest setting' - .' => Koha::Exceptions::Patron::Message::Preference::DigestNotAvailable'); + .' => Koha::Exceptions::Patron::MessagePreference::DigestNotAvailable'); is ($@->message_name, $attribute->message_name, 'The previous exception tells us' .' which message it was'); eval { - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, message_transport_types => [], wants_digest => 0, })->store }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::DigestRequired', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::DigestRequired', 'Adding a message preference, that requires digest, with no digest' - .' => Koha::Exceptions::Patron::Message::Preference::DigestRequired'); + .' => Koha::Exceptions::Patron::MessagePreference::DigestRequired'); is ($@->message_name, $attribute->message_name, 'The previous exception tells us' .' which message it was'); eval { - Koha::Patron::Message::Preference->new({ + Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => -1, message_transport_types => [], })->store }; - is (ref $@, 'Koha::Exceptions::Patron::Message::Preference::AttributeNotFound', + is (ref $@, 'Koha::Exceptions::Patron::MessagePreference::AttributeNotFound', 'Adding a message preference with invalid message_transport_type' - .' => KKoha::Exceptions::Patron::Message::Preference::AttributeNotFound'); + .' => KKoha::Exceptions::Patron::MessagePreference::AttributeNotFound'); is ($@->message_attribute_id, -1, 'The previous exception tells' .' us which message attribute id it was.'); @@ -702,10 +702,10 @@ subtest 'Test adding a new preference with invalid parameters' => sub { $schema->storage->txn_begin; - my $attribute = $builder->build_object({ class => 'Koha::Patron::Message::Attributes' }); + my $attribute = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Attributes' }); my $letter = build_a_test_letter(); - my $mtt = $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); - Koha::Patron::Message::Transport->new({ + my $mtt = $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attribute->message_attribute_id, message_transport_type => $mtt->message_transport_type, is_digest => 0, @@ -713,7 +713,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { letter_code => $letter->code, })->store; my $patron = $builder->build_object({ class => 'Koha::Patrons' }); - my $preference = Koha::Patron::Message::Preference->new({ + my $preference = Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, @@ -721,7 +721,7 @@ subtest 'Test adding a new preference with invalid parameters' => sub { })->store; ok($preference->borrower_message_preference_id, 'Added a new messaging preference for patron.'); - eval { Koha::Patron::Message::Preference->new({ + eval { Koha::Patron::MessagePreference->new({ borrowernumber => $patron->borrowernumber, message_attribute_id => $attribute->message_attribute_id, wants_digest => 0, @@ -746,7 +746,7 @@ sub build_a_test_attribute { value => $params, }); - return Koha::Patron::Message::Attributes->find( + return Koha::Patron::MessagePreference::Attributes->find( $attribute->{message_attribute_id} ); } @@ -782,10 +782,10 @@ sub build_a_test_category_preference { : build_a_test_attribute($params->{days_in_advance}); my $letter = $params->{letter} ? $params->{letter} : build_a_test_letter(); - my $mtt1 = $params->{mtt1} ? $params->{mtt1} : $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); - my $mtt2 = $params->{mtt2} ? $params->{mtt2} : $builder->build_object({ class => 'Koha::Patron::Message::Transport::Types' }); + my $mtt1 = $params->{mtt1} ? $params->{mtt1} : $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); + my $mtt2 = $params->{mtt2} ? $params->{mtt2} : $builder->build_object({ class => 'Koha::Patron::MessagePreference::Transport::Types' }); - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attr->message_attribute_id, message_transport_type => $mtt1->message_transport_type, is_digest => $params->{digest} ? 1 : 0, @@ -793,7 +793,7 @@ sub build_a_test_category_preference { letter_code => $letter->code, })->store; - Koha::Patron::Message::Transport->new({ + Koha::Patron::MessagePreference::Transport->new({ message_attribute_id => $attr->message_attribute_id, message_transport_type => $mtt2->message_transport_type, is_digest => $params->{digest} ? 1 : 0, @@ -801,7 +801,7 @@ sub build_a_test_category_preference { letter_code => $letter->code, })->store; - my $default = Koha::Patron::Message::Preference->new({ + my $default = Koha::Patron::MessagePreference->new({ categorycode => $patron->categorycode, message_attribute_id => $attr->message_attribute_id, wants_digest => $params->{digest} ? 1 : 0, @@ -809,11 +809,11 @@ sub build_a_test_category_preference { ? $params->{days_in_advance} : undef, })->store; - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $default->borrower_message_preference_id, message_transport_type => $mtt1->message_transport_type, })->store; - Koha::Patron::Message::Transport::Preference->new({ + Koha::Patron::MessagePreference::Transport::Preference->new({ borrower_message_preference_id => $default->borrower_message_preference_id, message_transport_type => $mtt2->message_transport_type, })->store; @@ -827,7 +827,7 @@ sub build_a_test_complete_preference { my ($default, $mtt1, $mtt2) = build_a_test_category_preference($params); my $patron = $params->{patron}; $patron->set_default_messaging_preferences; - return (Koha::Patron::Message::Preferences->search({ + return (Koha::Patron::MessagePreferences->search({ borrowernumber => $patron->borrowernumber })->next, $mtt1, $mtt2); } -- 2.25.1