|
Lines 20-26
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 15; |
23 |
use Test::More tests => 16; |
| 24 |
|
24 |
|
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
|
Lines 1200-1202
subtest 'change_type() tests' => sub {
Link Here
|
| 1200 |
|
1200 |
|
| 1201 |
$schema->storage->txn_rollback; |
1201 |
$schema->storage->txn_rollback; |
| 1202 |
}; |
1202 |
}; |
| 1203 |
- |
1203 |
|
|
|
1204 |
subtest 'strings_map() tests' => sub { |
| 1205 |
|
| 1206 |
plan tests => 3; |
| 1207 |
|
| 1208 |
$schema->txn_begin; |
| 1209 |
|
| 1210 |
my $av = Koha::AuthorisedValue->new( |
| 1211 |
{ |
| 1212 |
category => 'HOLD_CANCELLATION', |
| 1213 |
authorised_value => 'JUST_BECAUSE', |
| 1214 |
lib => 'Just because', |
| 1215 |
lib_opac => 'Serious reasons', |
| 1216 |
} |
| 1217 |
)->store; |
| 1218 |
|
| 1219 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1220 |
|
| 1221 |
my $hold = $builder->build_object( |
| 1222 |
{ |
| 1223 |
class => 'Koha::Holds', |
| 1224 |
value => { cancellation_reason => $av->authorised_value, branchcode => $library->id } |
| 1225 |
} |
| 1226 |
); |
| 1227 |
|
| 1228 |
my $strings_map = $hold->strings_map( { public => 0 } ); |
| 1229 |
is_deeply( |
| 1230 |
$strings_map, |
| 1231 |
{ |
| 1232 |
pickup_library_id => { str => $library->branchname, type => 'library' }, |
| 1233 |
cancellation_reason => { str => $av->lib, type => 'av', category => 'HOLD_CANCELLATION' }, |
| 1234 |
}, |
| 1235 |
'Strings map is correct' |
| 1236 |
); |
| 1237 |
|
| 1238 |
$strings_map = $hold->strings_map( { public => 1 } ); |
| 1239 |
is_deeply( |
| 1240 |
$strings_map, |
| 1241 |
{ |
| 1242 |
pickup_library_id => { str => $library->branchname, type => 'library' }, |
| 1243 |
cancellation_reason => { str => $av->lib_opac, type => 'av', category => 'HOLD_CANCELLATION' }, |
| 1244 |
}, |
| 1245 |
'Strings map is correct (OPAC)' |
| 1246 |
); |
| 1247 |
|
| 1248 |
$av->delete(); |
| 1249 |
|
| 1250 |
$strings_map = $hold->strings_map( { public => 1 } ); |
| 1251 |
is_deeply( |
| 1252 |
$strings_map, |
| 1253 |
{ |
| 1254 |
pickup_library_id => { str => $library->branchname, type => 'library' }, |
| 1255 |
cancellation_reason => { str => $hold->cancellation_reason, type => 'av', category => 'HOLD_CANCELLATION' }, |
| 1256 |
}, |
| 1257 |
'Strings map shows the cancellation_value when AV not present' |
| 1258 |
); |
| 1259 |
|
| 1260 |
$schema->txn_rollback; |
| 1261 |
}; |