Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::NoWarnings; |
24 |
use Test::NoWarnings; |
25 |
|
25 |
|
Lines 113-115
subtest 'edititem() tests' => sub {
Link Here
|
113 |
|
113 |
|
114 |
$schema->storage->txn_rollback; |
114 |
$schema->storage->txn_rollback; |
115 |
}; |
115 |
}; |
116 |
- |
116 |
|
|
|
117 |
subtest 'metadata() tests' => sub { |
118 |
|
119 |
plan tests => 8; |
120 |
|
121 |
$schema->storage->txn_begin; |
122 |
|
123 |
# Create a test ILL request |
124 |
my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } ); |
125 |
|
126 |
# Add various attributes including some that should be ignored |
127 |
$request->add_or_update_attributes( |
128 |
{ |
129 |
title => 'Test Title', |
130 |
author => 'Test Author', |
131 |
isbn => '1234567890', |
132 |
year => '2023', |
133 |
custom_field => 'custom_value', |
134 |
|
135 |
# These should be ignored by metadata() |
136 |
requested_partners => 'partner@example.com', |
137 |
type => 'book', |
138 |
copyrightclearance_confirmed => '1', |
139 |
unauthenticated_email => 'user@example.com' |
140 |
} |
141 |
); |
142 |
|
143 |
my $backend = Koha::ILL::Backend::Standard->new; |
144 |
my $metadata = $backend->metadata($request); |
145 |
|
146 |
# Check that metadata is a hashref |
147 |
is( ref($metadata), 'HASH', 'metadata returns a hashref' ); |
148 |
|
149 |
# Check that included attributes are present (metadata uses display names) |
150 |
is( $metadata->{Title}, 'Test Title', 'Title included in metadata' ); |
151 |
is( $metadata->{Author}, 'Test Author', 'Author included in metadata' ); |
152 |
is( $metadata->{ISBN}, '1234567890', 'ISBN included in metadata' ); |
153 |
is( $metadata->{Year}, '2023', 'Year included in metadata' ); |
154 |
is( $metadata->{Custom_field}, 'custom_value', 'Custom field included in metadata' ); |
155 |
|
156 |
# Check that ignored attributes are excluded |
157 |
ok( !exists $metadata->{Requested_partners}, 'requested_partners excluded from metadata' ); |
158 |
ok( !exists $metadata->{Copyrightclearance_confirmed}, 'copyrightclearance_confirmed excluded from metadata' ); |
159 |
|
160 |
$schema->storage->txn_rollback; |
161 |
}; |