|
Lines 1-68
Link Here
|
| 1 |
#!/usr/bin/perl |
|
|
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it under the |
| 6 |
# terms of the GNU General Public License as published by the Free Software |
| 7 |
# Foundation; either version 3 of the License, or (at your option) any later |
| 8 |
# version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
| 11 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
| 12 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License along |
| 15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
| 16 |
|
| 17 |
use Modern::Perl; |
| 18 |
|
| 19 |
use Test::More tests => 2; |
| 20 |
use Test::MockModule; |
| 21 |
|
| 22 |
use Koha::Database; |
| 23 |
|
| 24 |
use t::lib::TestBuilder; |
| 25 |
|
| 26 |
BEGIN { |
| 27 |
use_ok('Koha::Template::Plugin::Biblio'); |
| 28 |
} |
| 29 |
|
| 30 |
my $schema = Koha::Database->schema; |
| 31 |
my $builder = t::lib::TestBuilder->new; |
| 32 |
|
| 33 |
subtest 'CanBeEdited() tests' => sub { |
| 34 |
|
| 35 |
plan tests => 3; |
| 36 |
|
| 37 |
$schema->storage->txn_begin; |
| 38 |
|
| 39 |
my $biblio = $builder->build_sample_biblio(); |
| 40 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 41 |
|
| 42 |
my $can_be_edited; |
| 43 |
|
| 44 |
my $mock_biblio = Test::MockModule->new('Koha::Biblio'); |
| 45 |
$mock_biblio->mock( 'can_be_edited', sub { return $can_be_edited; } ); |
| 46 |
|
| 47 |
my $plugin = Koha::Template::Plugin::Biblio->new(); |
| 48 |
|
| 49 |
$can_be_edited = undef; |
| 50 |
is( |
| 51 |
$plugin->CanBeEdited( $biblio, $patron ), undef, |
| 52 |
'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' |
| 53 |
); |
| 54 |
|
| 55 |
$can_be_edited = 0; |
| 56 |
is( |
| 57 |
$plugin->CanBeEdited( $biblio, $patron ), 0, |
| 58 |
'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' |
| 59 |
); |
| 60 |
|
| 61 |
$can_be_edited = 1; |
| 62 |
is( |
| 63 |
$plugin->CanBeEdited( $biblio, $patron ), 1, |
| 64 |
'CanBeEdited is just a wrapper around Koha::Biblio->can_be_edited()' |
| 65 |
); |
| 66 |
|
| 67 |
$schema->storage->txn_rollback; |
| 68 |
}; |
| 69 |
- |