|
Line 0
Link Here
|
| 0 |
- |
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 t::lib::TestBuilder; |
| 23 |
use t::lib::Mocks; |
| 24 |
|
| 25 |
BEGIN { |
| 26 |
use_ok('Koha::Template::Plugin::Frameworks'); |
| 27 |
} |
| 28 |
|
| 29 |
my $schema = Koha::Database->schema; |
| 30 |
my $builder = t::lib::TestBuilder->new; |
| 31 |
|
| 32 |
$schema->storage->txn_begin; |
| 33 |
|
| 34 |
subtest 'GetName tests' => sub { |
| 35 |
plan tests => 3; |
| 36 |
|
| 37 |
my $framework = $builder->build_object({ class => 'Koha::BiblioFrameworks' })->store; |
| 38 |
|
| 39 |
my $plugin = Koha::Template::Plugin::Frameworks->new(); |
| 40 |
|
| 41 |
my $name = $plugin->GetName( $framework->frameworkcode ); |
| 42 |
is( $name, $framework->frameworktext, "Name correctly fetched" ); |
| 43 |
|
| 44 |
$name = $plugin->GetName(); |
| 45 |
is( $name, q{}, "Nothing returned if nothing passed" ); |
| 46 |
|
| 47 |
$framework->delete; |
| 48 |
$name = $plugin->GetName( $framework->frameworkcode ); |
| 49 |
is( $name, $framework->frameworkcode, "When framework not found, we get the code back" ); |
| 50 |
}; |
| 51 |
|
| 52 |
$schema->storage->txn_rollback; |