From 848512d46627f9a3b6748c8a9af0f50ee6869012 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 19 Nov 2019 13:22:18 -0300 Subject: [PATCH] Bug 23634: Add tests for is_superlibrarian Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy Signed-off-by: Aleisha Amohia (cherry picked from commit 6cbe60e25de95b81b11766764846864a46b8b88b) Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/Koha/Patron.t | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 t/db_dependent/Koha/Patron.t diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t new file mode 100644 index 0000000000..c9f4e07d37 --- /dev/null +++ b/t/db_dependent/Koha/Patron.t @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +# Copyright 2019 Koha Development team +# +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More tests => 1; +use Test::Exception; + +use Koha::Database; +use Koha::Patrons; + +use t::lib::TestBuilder; +use t::lib::Mocks; + +my $schema = Koha::Database->new->schema; +my $builder = t::lib::TestBuilder->new; + + +subtest 'is_superlibrarian() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + flags => 16 + } + } + ); + + ok( !$patron->is_superlibrarian, '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' ); + + $schema->storage->txn_rollback; +}; -- 2.39.5