Bug 38751: Add tests

prove t/db_dependent/Koha/ILL/Request.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2024-12-19 11:57:55 +00:00 committed by Katrin Fischer
parent 9fc470c0a8
commit 2a6bc075f6
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 50 additions and 1 deletions

View File

@ -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,55 @@ 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;