From 22c30fe5a018b8558257914bfb4b7b7de43d8d26 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 23 Jul 2020 13:58:45 +0200 Subject: [PATCH] Bug 20469: Add test for ItemTypes plugin Content-Type: text/plain; charset=utf-8 Test plan: Run the test. Signed-off-by: Marcel de Rooy --- t/db_dependent/Template/Plugin/ItemTypes.t | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 t/db_dependent/Template/Plugin/ItemTypes.t diff --git a/t/db_dependent/Template/Plugin/ItemTypes.t b/t/db_dependent/Template/Plugin/ItemTypes.t new file mode 100644 index 0000000000..8d2030de5a --- /dev/null +++ b/t/db_dependent/Template/Plugin/ItemTypes.t @@ -0,0 +1,44 @@ +#!/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 => 1; + +use t::lib::TestBuilder; +use t::lib::Mocks; + +use Koha::Database; +use Koha::Template::Plugin::ItemTypes; + +my $schema = Koha::Database->schema; +our $builder = t::lib::TestBuilder->new; +$schema->storage->txn_begin; + +subtest 'Notforloan' => sub { + plan tests => 3; + + my $itemtype1 = $builder->build_object({ class => 'Koha::ItemTypes' }); + my $itemtype2 = $builder->build_object({ class => 'Koha::ItemTypes' }); + $itemtype2->notforloan(1)->store; + + my $template_plugin = Koha::Template::Plugin::ItemTypes->new; + + is( $template_plugin->Notforloan('SHOULD_NOT_BE_THERE'), undef, 'Undefined when not found' ); + is( $template_plugin->Notforloan($itemtype1->itemtype), 0, 'Itemtype 1 not set' ); + is( $template_plugin->Notforloan($itemtype2->itemtype), 1, 'Itemtype 2 set' ); +}; + +$schema->storage->txn_rollback; -- 2.11.0