From e948533ab65db38e0cca9c84ffb84cfef14c029f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 3 Sep 2020 10:20:32 +0200 Subject: [PATCH] Bug 23634: Make is_superlibrarian return 1 or 0 --- Koha/Patron.pm | 2 +- t/db_dependent/Koha/Patron.t | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 42bd0886e5..9c8de9b014 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1371,7 +1371,7 @@ Return true if the patron is a superlibrarian. sub is_superlibrarian { my ($self) = @_; - return $self->has_permission( { superlibrarian => 1 } ); + return $self->has_permission( { superlibrarian => 1 } ) ? 1 : 0; } =head3 is_adult diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index fb078a83cb..d2aff3353c 100644 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -214,7 +214,7 @@ subtest 'login_attempts tests' => sub { subtest 'is_superlibrarian() tests' => sub { - plan tests => 2; + plan tests => 3; $schema->storage->txn_begin; @@ -228,10 +228,13 @@ subtest 'is_superlibrarian() tests' => sub { } ); - ok( !$patron->is_superlibrarian, 'Patron is not a superlibrarian and the method returns the correct value' ); + is( $patron->is_superlibrarian, 0, 'Patron is not a superlibrarian and the method returns the correct value' ); $patron->flags(1)->store->discard_changes; - ok( $patron->is_superlibrarian, 'Patron is a superlibrarian and the method returns the correct value' ); + is( $patron->is_superlibrarian, 1, 'Patron is a superlibrarian and the method returns the correct value' ); + + $patron->flags(0)->store->discard_changes; + is( $patron->is_superlibrarian, 0, 'Patron is not a superlibrarian and the method returns the correct value' ); $schema->storage->txn_rollback; }; -- 2.20.1