From f0493d22b186732d9c2d9ea7564ca5930d532b24 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 26 May 2017 12:58:21 -0400 Subject: [PATCH] Bug 1985: perlcritic --- Koha/Review.pm | 14 +++++++------- opac/opac-review.pl | 2 +- t/db_dependent/Koha/Reviews.t | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Koha/Review.pm b/Koha/Review.pm index 75da3e3..97fa682 100644 --- a/Koha/Review.pm +++ b/Koha/Review.pm @@ -68,24 +68,24 @@ sub _type { return 'Review'; } -=head3 SendReviewAlert +=head3 send_review_alert - $review->SendReviewAlert($parameters); + $review->send_review_alert($parameters); Queue an outgoing email alert when a borrower posts a review, using the passed parameters in a hash reference. =cut -sub SendReviewAlert { +sub send_review_alert { my ( $self, $params ) = @_; my $borrowernumber = $params->{borrowernumber}; my $reviewid = $params->{reviewid}; my $biblionumber = $params->{biblionumber}; - my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail'); - unless ($moderatorEmail) { + my $moderator_email = C4::Context->preference('CommentModeratorsEmail'); + if (!$moderator_email) { carp 'CommentModeratorsEmail is not set!'; return; } @@ -100,7 +100,7 @@ sub SendReviewAlert { 'biblioitems' => $biblionumber, } ); - unless ($letter) { + if (!$letter) { carp 'COMMENT_CREATED member letter not found!'; return; } @@ -109,7 +109,7 @@ sub SendReviewAlert { letter => $letter, borrowernumber => $borrowernumber, message_transport_type => 'email', - to_address => $moderatorEmail, + to_address => $moderator_email, }); return 1; diff --git a/opac/opac-review.pl b/opac/opac-review.pl index fe31a9e..7197a19 100755 --- a/opac/opac-review.pl +++ b/opac/opac-review.pl @@ -106,7 +106,7 @@ if ( !@errors && $submitting ) { $affectedreview = $newreview; } if ($reviewid) { - $affectedreview->SendReviewAlert( + $affectedreview->send_review_alert( { 'borrowernumber' => $borrowernumber, 'reviewid' => $reviewid, diff --git a/t/db_dependent/Koha/Reviews.t b/t/db_dependent/Koha/Reviews.t index e10da80..91250ab 100644 --- a/t/db_dependent/Koha/Reviews.t +++ b/t/db_dependent/Koha/Reviews.t @@ -73,27 +73,27 @@ is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id $retrieved_review_1_1->delete; is( Koha::Reviews->search->count, $nb_of_reviews + 2, 'Delete should have deleted the review' ); -# Test SendReview Alert +# Test send_review_alert # empty CommentModeratorsEmail t::lib::Mocks::mock_preference('CommentModeratorsEmail',undef); warning_like { -$new_review_1_2->SendReviewAlert({ +$new_review_1_2->send_review_alert({ borrowernumber => $patron_1->{borrowernumber}, biblionumber => $biblio_2->{biblionumber}, reviewid => $new_review_1_2->reviewid -}) } qr/CommentModeratorsEmail is not set!/, 'SendReviewAlert triggered expected CommentModeratorsEmail warning.'; -is( Koha::Notice::Messages->search->count, $nb_of_messages, 'SendReviewAlert lacking CommentModeratorsEmail triggered nothing.' ); +}) } qr/CommentModeratorsEmail is not set!/, 'send_review_alert triggered expected CommentModeratorsEmail warning.'; +is( Koha::Notice::Messages->search->count, $nb_of_messages, 'send_review_alert lacking CommentModeratorsEmail triggered nothing.' ); # set CommentModeratorsEmail t::lib::Mocks::mock_preference('CommentModeratorsEmail','test@test.test'); warning_is { -$new_review_1_2->SendReviewAlert({ +$new_review_1_2->send_review_alert({ borrowernumber => $patron_1->{borrowernumber}, biblionumber => $biblio_2->{biblionumber}, reviewid => $new_review_1_2->reviewid -}) } '', 'SendReviewAlert triggered no warnings as expected.'; -is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'SendReviewAlert triggered notice.' ); +}) } '', 'send_review_alert triggered no warnings as expected.'; +is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'send_review_alert triggered notice.' ); # letter missing Koha::Notice::Templates->search({ @@ -101,14 +101,14 @@ Koha::Notice::Templates->search({ code => 'COMMENT_CREATED' })->delete; warnings_like { -$new_review_1_2->SendReviewAlert({ +$new_review_1_2->send_review_alert({ borrowernumber => $patron_1->{borrowernumber}, biblionumber => $biblio_2->{biblionumber}, reviewid => $new_review_1_2->reviewid }) } [ qr/No members COMMENT_CREATED letter transported by email/, - qr/COMMENT_CREATED member letter not found!/ ] , 'SendReviewAlert triggered expected COMMENT_CREATED warnings.'; -is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'SendReviewAlert lacking letter triggered nothing new.' ); + qr/COMMENT_CREATED member letter not found!/ ] , 'send_review_alert triggered expected COMMENT_CREATED warnings.'; +is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'send_review_alert lacking letter triggered nothing new.' ); $schema->storage->txn_rollback; -- 2.1.4