@@ -, +, @@ --- Koha/Template/Plugin/Biblio.pm | 6 +++ t/db_dependent/Template/Plugin/Biblio.t | 68 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 t/db_dependent/Template/Plugin/Biblio.t --- a/Koha/Template/Plugin/Biblio.pm +++ a/Koha/Template/Plugin/Biblio.pm @@ -69,4 +69,10 @@ sub RecallsCount { return $recalls->count; } +sub CanBeEdited { + my ( $self, $biblio, $patron ) = @_; + + return $biblio->can_be_edited($patron); +} + 1; --- a/t/db_dependent/Template/Plugin/Biblio.t +++ a/t/db_dependent/Template/Plugin/Biblio.t @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# 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 => 2; +use Test::MockModule; + +use Koha::Database; + +use t::lib::TestBuilder; + +BEGIN { + use_ok('Koha::Template::Plugin::Biblio'); +} + +my $schema = Koha::Database->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'CanBeEdited() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + + my $can_be_edited; + + my $mock_biblio = Test::MockModule->new('Koha::Biblio'); + $mock_biblio->mock( 'can_be_edited', sub { return $can_be_edited; } ); + + my $plugin = Koha::Template::Plugin::Biblio->new(); + + $can_be_edited = undef; + is( + $plugin->CanBeEdited( $biblio, $patron ), undef, + 'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' + ); + + $can_be_edited = 0; + is( + $plugin->CanBeEdited( $biblio, $patron ), 0, + 'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' + ); + + $can_be_edited = 1; + is( + $plugin->CanBeEdited( $biblio, $patron ), 1, + 'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' + ); + + $schema->storage->txn_rollback; +}; --