Lines 1216-1224
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents with Inclu
Link Here
|
1216 |
}; |
1216 |
}; |
1217 |
|
1217 |
|
1218 |
subtest 'marc_records_to_documents should set the "available" field' => sub { |
1218 |
subtest 'marc_records_to_documents should set the "available" field' => sub { |
1219 |
plan tests => 8; |
1219 |
plan tests => 14; |
1220 |
|
1220 |
|
1221 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
1221 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
|
|
1222 |
t::lib::Mocks::mock_preference( 'UnavailableNotForLoan', undef ); |
1222 |
my $dbh = C4::Context->dbh; |
1223 |
my $dbh = C4::Context->dbh; |
1223 |
|
1224 |
|
1224 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
1225 |
my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch'); |
Lines 1276-1281
subtest 'marc_records_to_documents should set the "available" field' => sub {
Link Here
|
1276 |
$docs->[0]->{available}, \1, |
1277 |
$docs->[0]->{available}, \1, |
1277 |
'a biblio with at least one item that has no particular status is available' |
1278 |
'a biblio with at least one item that has no particular status is available' |
1278 |
); |
1279 |
); |
|
|
1280 |
|
1281 |
t::lib::Mocks::mock_preference( 'UnavailableNotForLoan', join( ',', '-1', '1' ) ); |
1282 |
$biblio = $builder->build_sample_biblio; |
1283 |
$marc_record_1 = $biblio->metadata->record; |
1284 |
|
1285 |
$item = $builder->build_sample_item( |
1286 |
{ |
1287 |
biblionumber => $biblio->biblionumber, |
1288 |
} |
1289 |
); |
1290 |
|
1291 |
$item->notforloan(-1)->store(); |
1292 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1293 |
is_deeply( |
1294 |
$docs->[0]->{available}, \0, |
1295 |
'A biblio with one item whose notforloan value is selected in UnavailableNotForLoan should be considered not available' |
1296 |
); |
1297 |
|
1298 |
$item->set( { notforloan => 1 } )->store(); |
1299 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1300 |
is_deeply( |
1301 |
$docs->[0]->{available}, \0, |
1302 |
'A biblio with one item whose notforloan value is selected in UnavailableNotForLoan should be considered not available' |
1303 |
); |
1304 |
|
1305 |
$item->set( { notforloan => 2 } )->store(); |
1306 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1307 |
is_deeply( |
1308 |
$docs->[0]->{available}, \1, |
1309 |
'A biblio with one item whose notforloan value is not selected in UnavailableNotForLoan should be considered available' |
1310 |
); |
1311 |
|
1312 |
t::lib::Mocks::mock_preference( 'UnavailableWithDrawn', join( ',', '-1', '1' ) ); |
1313 |
$biblio = $builder->build_sample_biblio; |
1314 |
$marc_record_1 = $biblio->metadata->record; |
1315 |
|
1316 |
$item = $builder->build_sample_item( |
1317 |
{ |
1318 |
biblionumber => $biblio->biblionumber, |
1319 |
} |
1320 |
); |
1321 |
|
1322 |
$item->withdrawn(-1)->store(); |
1323 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1324 |
is_deeply( |
1325 |
$docs->[0]->{available}, \0, |
1326 |
'A biblio with one item whose withdrawn value is selected in UnavailableWithDrawn should be considered not available' |
1327 |
); |
1328 |
|
1329 |
$item->set( { withdrawn => 1 } )->store(); |
1330 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1331 |
is_deeply( |
1332 |
$docs->[0]->{available}, \0, |
1333 |
'A biblio with one item whose withdrawn value is selected in UnavailableWithDrawn should be considered not available' |
1334 |
); |
1335 |
|
1336 |
$item->set( { withdrawn => 2 } )->store(); |
1337 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1338 |
is_deeply( |
1339 |
$docs->[0]->{available}, \1, |
1340 |
'A biblio with one item whose withdrawn value is not selected in UnavailableWithDrawn should be considered available' |
1341 |
); |
1279 |
}; |
1342 |
}; |
1280 |
|
1343 |
|
1281 |
$schema->storage->txn_rollback; |
1344 |
$schema->storage->txn_rollback; |
1282 |
- |
|
|