Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 5; |
20 |
use Test::More tests => 6; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
23 |
|
23 |
|
Lines 281-288
subtest '_get_biblio_for_export' => sub {
Link Here
|
281 |
|
281 |
|
282 |
}; |
282 |
}; |
283 |
|
283 |
|
|
|
284 |
subtest '_get_record_for_export MARC field conditions' => sub { |
285 |
plan tests => 11; |
284 |
|
286 |
|
|
|
287 |
my $biblio = MARC::Record->new(); |
288 |
$biblio->leader('00266nam a22001097a 4500'); |
289 |
$biblio->append_fields( |
290 |
MARC::Field->new( '100', ' ', ' ', a => 'Thurber, James' ), |
291 |
MARC::Field->new( '245', ' ', ' ', a => 'The 13 Clocks' ), |
292 |
MARC::Field->new( '080', ' ', ' ', a => '12345' ), |
293 |
MARC::Field->new( '035', ' ', ' ', a => '(TEST)123' ), |
294 |
MARC::Field->new( '035', ' ', ' ', a => '(TEST)1234' ), |
295 |
); |
296 |
my ( $biblionumber ) = AddBiblio( $biblio, '' ); |
297 |
my $record; |
285 |
|
298 |
|
|
|
299 |
$record = Koha::Exporter::Record::_get_record_for_export( |
300 |
{ |
301 |
record_id => $biblionumber, |
302 |
record_conditions => [['080', 'a', '=', '12345']], |
303 |
record_type => 'bibs', |
304 |
} |
305 |
); |
306 |
ok( $record, "Record condition \"080a=12345\" should match" ); |
286 |
|
307 |
|
287 |
$schema->storage->txn_rollback; |
308 |
$record = Koha::Exporter::Record::_get_record_for_export( |
|
|
309 |
{ |
310 |
record_id => $biblionumber, |
311 |
record_conditions => [['080', 'a', '!=', '12345']], |
312 |
record_type => 'bibs', |
313 |
} |
314 |
); |
315 |
is( $record, undef, "Record condition \"080a!=12345\" should not match" ); |
316 |
|
317 |
$record = Koha::Exporter::Record::_get_record_for_export( |
318 |
{ |
319 |
record_id => $biblionumber, |
320 |
record_conditions => [['080', 'a', '>', '1234']], |
321 |
record_type => 'bibs', |
322 |
} |
323 |
); |
324 |
ok( $record, "Record condition \"080a>1234\" should match" ); |
325 |
|
326 |
$record = Koha::Exporter::Record::_get_record_for_export( |
327 |
{ |
328 |
record_id => $biblionumber, |
329 |
record_conditions => [['080', 'a', '<', '123456']], |
330 |
record_type => 'bibs', |
331 |
} |
332 |
); |
333 |
ok( $record, "Record condition \"080a<123456\" should match" ); |
334 |
|
335 |
$record = Koha::Exporter::Record::_get_record_for_export( |
336 |
{ |
337 |
record_id => $biblionumber, |
338 |
record_conditions => [['080', 'a', '>', '123456']], |
339 |
record_type => 'bibs', |
340 |
} |
341 |
); |
342 |
is( $record, undef, "Record condition \"080a>123456\" should not match" ); |
343 |
|
344 |
|
345 |
## Multiple subfields |
346 |
|
347 |
$record = Koha::Exporter::Record::_get_record_for_export( |
348 |
{ |
349 |
record_id => $biblionumber, |
350 |
record_conditions => [['035', 'a', '!=', 'TEST(12345)']], |
351 |
record_type => 'bibs', |
352 |
} |
353 |
); |
354 |
ok( $record, "Record condition \"035a!=TEST(12345)\" should match" ); |
355 |
|
356 |
$record = Koha::Exporter::Record::_get_record_for_export( |
357 |
{ |
358 |
record_id => $biblionumber, |
359 |
record_conditions => [['035', 'a', '=', 'TEST(1234)']], |
360 |
record_type => 'bibs', |
361 |
} |
362 |
); |
363 |
is( $record, undef, "Record condition \"035a=TEST(1234)\" should not match" ); # Since matching all subfields required |
364 |
|
365 |
|
366 |
## Multiple conditions |
367 |
|
368 |
$record = Koha::Exporter::Record::_get_record_for_export( |
369 |
{ |
370 |
record_id => $biblionumber, |
371 |
record_conditions => [['035', 'a', '!=', 'TEST(12345)'], ['080', 'a', '>', '1234']], |
372 |
record_type => 'bibs', |
373 |
} |
374 |
); |
375 |
ok( $record, "Record condition \"035a!=TEST(12345),080a>1234\" should match" ); |
376 |
|
377 |
$record = Koha::Exporter::Record::_get_record_for_export( |
378 |
{ |
379 |
record_id => $biblionumber, |
380 |
record_conditions => [['035', 'a', '!=', 'TEST(12345)'], ['080', 'a', '<', '1234']], |
381 |
record_type => 'bibs', |
382 |
} |
383 |
); |
384 |
is( $record, undef, "Record condition \"035a!=TEST(12345),080a<1234\" should not match" ); |
385 |
|
386 |
|
387 |
## exists/not_exists |
388 |
|
389 |
$record = Koha::Exporter::Record::_get_record_for_export( |
390 |
{ |
391 |
record_id => $biblionumber, |
392 |
record_conditions => [['035', 'a', '?']], |
393 |
record_type => 'bibs', |
394 |
} |
395 |
); |
396 |
ok( $record, "Record condition \"exists(035a)\" should match" ); |
288 |
|
397 |
|
289 |
- |
398 |
$record = Koha::Exporter::Record::_get_record_for_export( |
|
|
399 |
{ |
400 |
record_id => $biblionumber, |
401 |
record_conditions => [['035', 'a', '!?']], |
402 |
record_type => 'bibs', |
403 |
record_type => 'bibs', |
404 |
} |
405 |
); |
406 |
is( $record, undef, "Record condition \"not_exists(035a)\" should not match" ); |
407 |
}; |
408 |
|
409 |
$schema->storage->txn_rollback; |