From 40605380367549eb02d87a90042935964a37ab40 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 19 Dec 2024 11:57:55 +0000 Subject: [PATCH] Bug 38751: Add tests prove t/db_dependent/Koha/ILL/Request.t --- t/db_dependent/Koha/ILL/Request.t | 49 ++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/ILL/Request.t b/t/db_dependent/Koha/ILL/Request.t index fe8f1631c90..4a35b1cf2f7 100755 --- a/t/db_dependent/Koha/ILL/Request.t +++ b/t/db_dependent/Koha/ILL/Request.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::MockModule; use Koha::ILL::Requests; @@ -68,6 +68,53 @@ subtest 'patron() tests' => sub { $schema->storage->txn_rollback; }; +subtest 'extended_attributes() tests' => sub { + + plan tests => 4; + + $schema->storage->txn_begin; + + my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } ); + + is( + $request->extended_attributes->count, 0, + 'extended_attributes() returns empty if no extended attributes are set' + ); + + my $attribute = $builder->build_object( + { + class => 'Koha::ILL::Request::Attributes', + value => { + illrequest_id => $request->illrequest_id, + type => 'custom_attribute', + value => 'custom_value' + } + } + ); + + is_deeply( + $request->extended_attributes->next, $attribute, + 'extended_attributes() returns empty if no extended attributes are set' + ); + + $request->extended_attributes([ + { type => 'type', value => 'type_value' }, + { type => 'type2', value => 'type2_value' }, + ]); + + is( + $request->extended_attributes->count, 3, + 'extended_attributes() returns the correct amount of attributes' + ); + + is( + $request->extended_attributes->find({ type => 'type' })->value, 'type_value', + 'extended_attributes() contains the correct attribute' + ); + + $schema->storage->txn_rollback; +}; + subtest 'get_type_disclaimer_value() tests' => sub { plan tests => 2; -- 2.39.5