From 29da30e1d458a0fa75444933ba441eb7906f53fa Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 1 Jul 2019 16:06:42 +0100 Subject: [PATCH] Bug 17492: (RM follow-up) Use more specific method name Changed the method introduced into Koha::Patron from is_category_valid to the more specific is_valid_age to clarify it's intent to future developers. Signed-off-by: Martin Renvoize --- Koha/Patron.pm | 6 +++--- circ/circulation.pl | 2 +- members/moremember.pl | 2 +- t/db_dependent/Koha/Patrons.t | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 06124a8..b1d9b14 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -977,15 +977,15 @@ sub get_age { return $age; } -=head3 is_category_valid +=head3 is_valid_age -my $is_valid = $patron->is_category_valid +my $is_valid = $patron->is_valid_age Return 1 if patron's age is between allowed limits, returns 0 if it's not. =cut -sub is_category_valid { +sub is_valid_age { my ($self) = @_; my $age = $self->get_age; diff --git a/circ/circulation.pl b/circ/circulation.pl index 7191654..e7b4459 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -321,7 +321,7 @@ if ($patron) { } # Calculate and display patron's age - if ( !$patron->is_category_valid ) { + if ( !$patron->is_valid_age ) { $template->param( age_limitations => 1 ); $template->param( age_low => $patron->category->dateofbirthrequired ); $template->param( age_high => $patron->category->upperagelimit ); diff --git a/members/moremember.pl b/members/moremember.pl index defd5d4..33f833e 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -120,7 +120,7 @@ my $relatives_issues_count = Koha::Checkouts->count({ borrowernumber => \@relatives }); # Calculate and display patron's age -if ( !$patron->is_category_valid ) { +if ( !$patron->is_valid_age ) { $template->param( age_limitations => 1 ); $template->param( age_low => $patron->category->dateofbirthrequired ); $template->param( age_high => $patron->category->upperagelimit ); diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 75b91cc..bba4dfe 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -639,7 +639,7 @@ subtest 'get_age' => sub { $patron->delete; }; -subtest 'is_category_valid' => sub { +subtest 'is_valid_age' => sub { plan tests => 10; my $today = dt_from_string; @@ -664,34 +664,34 @@ subtest 'is_category_valid' => sub { $patron->dateofbirth( undef ); - is( $patron->is_category_valid, 1, 'Patron with no dateofbirth is always valid for any category'); + is( $patron->is_valid_age, 1, 'Patron with no dateofbirth is always valid for any category'); $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) ); - is( $patron->is_category_valid, 0, 'Patron is 12, so the age is above allowed range 5-10 years'); + is( $patron->is_valid_age, 0, 'Patron is 12, so the age is above allowed range 5-10 years'); $patron->dateofbirth( $today->clone->add( years => -3, months => -6, days => -1 ) ); - is( $patron->is_category_valid, 0, 'Patron is 3, so the age is below allowed range 5-10 years'); + is( $patron->is_valid_age, 0, 'Patron is 3, so the age is below allowed range 5-10 years'); $patron->dateofbirth( $today->clone->add( years => -7, months => -6, days => -1 ) ); - is( $patron->is_category_valid, 1, 'Patron is 7, so the age perfectly suits allowed range 5-10 years'); + is( $patron->is_valid_age, 1, 'Patron is 7, so the age perfectly suits allowed range 5-10 years'); $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 0 ) ); - is( $patron->is_category_valid, 1, 'Patron celebrates the 5th birthday today, so the age is allowed for this category'); + is( $patron->is_valid_age, 1, 'Patron celebrates the 5th birthday today, so the age is allowed for this category'); $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 1 ) ); - is( $patron->is_category_valid, 0, 'Patron will celebrate the 5th birthday tomorrow, so the age is NOT allowed for this category'); + is( $patron->is_valid_age, 0, 'Patron will celebrate the 5th birthday tomorrow, so the age is NOT allowed for this category'); $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => -1 ) ); - is( $patron->is_category_valid, 1, 'Patron celebrated the 5th birthday yesterday, so the age is allowed for this category'); + is( $patron->is_valid_age, 1, 'Patron celebrated the 5th birthday yesterday, so the age is allowed for this category'); $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 0 ) ); - is( $patron->is_category_valid, 0, 'Patron celebrate the 11th birthday today, so the age is NOT allowed for this category'); + is( $patron->is_valid_age, 0, 'Patron celebrate the 11th birthday today, so the age is NOT allowed for this category'); $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 1 ) ); - is( $patron->is_category_valid, 1, 'Patron will celebrate the 11th birthday tomorrow, so the age is allowed for this category'); + is( $patron->is_valid_age, 1, 'Patron will celebrate the 11th birthday tomorrow, so the age is allowed for this category'); $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => -1 ) ); - is( $patron->is_category_valid, 0, 'Patron celebrated the 11th birthday yesterday, so the age is NOT allowed for this category'); + is( $patron->is_valid_age, 0, 'Patron celebrated the 11th birthday yesterday, so the age is NOT allowed for this category'); $patron->delete; $category->delete; -- 1.7.2.5