From 457b24f5a826d3432a852a479dd7f64c9daa1288 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 20 May 2025 12:37:23 +0000 Subject: [PATCH] Bug 39944: Add tests prove t/db_dependent/Koha/ILL/Request.t --- t/db_dependent/Koha/ILL/Request.t | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/ILL/Request.t b/t/db_dependent/Koha/ILL/Request.t index bc0b2fb9647..b7956b0686a 100755 --- a/t/db_dependent/Koha/ILL/Request.t +++ b/t/db_dependent/Koha/ILL/Request.t @@ -20,7 +20,7 @@ use Modern::Perl; use Test::NoWarnings; -use Test::More tests => 6; +use Test::More tests => 7; use Test::MockModule; use Koha::ILL::Requests; @@ -197,3 +197,43 @@ subtest 'get_backend_plugin() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'trim_form_params() tests' => sub { + + plan tests => 4; + + $schema->storage->txn_begin; + + my $request = $builder->build_sample_ill_request(); + + my $params = { + 'pubmedid' => '', + 'doi' => ' abc', + 'type' => 'article', + 'backend' => 'Standard', + }; + + my $trimmed_params = $request->trim_form_params($params); + + is( + $trimmed_params->{doi}, 'abc', + 'param with leading white space is correctly trimmed' + ); + + is( + $trimmed_params->{pubmedid}, '', + 'empty param remains empty' + ); + + is( + $trimmed_params->{nonexistent}, undef, + 'undef param remains undef' + ); + + is( + $trimmed_params->{type}, $trimmed_params->{type}, + 'already trimmed param remains unchanged' + ); + + $schema->storage->txn_rollback; +}; -- 2.39.5