From 66d3a22110f186aff9bb77bff7491bde7fd76c4c Mon Sep 17 00:00:00 2001
From: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Date: Tue, 29 Oct 2024 11:12:25 +0000
Subject: [PATCH] Bug 37872: Add tests
$ prove t/db_dependent/Koha/ILL/Request.t
$ prove t/db_dependent/Koha/ILL/Request/Config.t
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
t/db_dependent/Koha/ILL/Request.t | 19 ++++++++++++++++++-
t/db_dependent/Koha/ILL/Request/Config.t | 17 ++++++++++++++++-
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/t/db_dependent/Koha/ILL/Request.t b/t/db_dependent/Koha/ILL/Request.t
index 2ec832949e4..fe8f1631c90 100755
--- a/t/db_dependent/Koha/ILL/Request.t
+++ b/t/db_dependent/Koha/ILL/Request.t
@@ -19,11 +19,12 @@
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 4;
use Test::MockModule;
use Koha::ILL::Requests;
+use t::lib::Mocks;
use t::lib::TestBuilder;
my $builder = t::lib::TestBuilder->new;
@@ -130,3 +131,19 @@ subtest 'get_type_disclaimer_date() tests' => sub {
$schema->storage->txn_rollback;
};
+
+subtest 'get_backend_plugin() tests' => sub {
+
+ plan tests => 1;
+
+ $schema->storage->txn_begin;
+
+ my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } );
+ t::lib::Mocks::mock_config( 'enable_plugins', 0 );
+ is(
+ $request->get_backend_plugin, undef,
+ 'get_backend_plugin returns undef if plugins are disabled'
+ );
+
+ $schema->storage->txn_rollback;
+};
diff --git a/t/db_dependent/Koha/ILL/Request/Config.t b/t/db_dependent/Koha/ILL/Request/Config.t
index f511726c308..2d4b60f2609 100755
--- a/t/db_dependent/Koha/ILL/Request/Config.t
+++ b/t/db_dependent/Koha/ILL/Request/Config.t
@@ -23,7 +23,7 @@ use t::lib::TestBuilder;
use Test::MockObject;
use Test::Exception;
-use Test::More tests => 5;
+use Test::More tests => 6;
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
@@ -487,5 +487,20 @@ subtest 'Final tests' => sub {
$schema->storage->txn_rollback;
};
+subtest 'get_backend_plugin_names() tests' => sub {
+
+ plan tests => 1;
+
+ $schema->storage->txn_begin;
+
+ my $config = Koha::ILL::Request::Config->new;
+ t::lib::Mocks::mock_config( 'enable_plugins', 0 );
+ is(
+ $config->get_backend_plugin_names(), 0,
+ 'get_backend_plugin_names returns empty list if plugins are disabled'
+ );
+
+ $schema->storage->txn_rollback;
+};
1;
--
2.47.0