From 42199c3fd3bffa3e091b65a65a93d96529b0e570 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 d3cc3f0e277..cc79b2d93b0 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 => 8; +use Test::More tests => 9; use Test::MockModule; use Koha::ILL::Requests; @@ -299,3 +299,43 @@ subtest 'add_or_update_attributes() 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