|
Lines 17-25
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 15; |
20 |
use Test::More tests => 16; |
| 21 |
|
21 |
|
| 22 |
use C4::Biblio qw( AddBiblio ModBiblio ); |
22 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
| 23 |
use Koha::Database; |
23 |
use Koha::Database; |
| 24 |
use Koha::Acquisition::Orders; |
24 |
use Koha::Acquisition::Orders; |
| 25 |
|
25 |
|
|
Lines 503-509
subtest 'suggestions() tests' => sub {
Link Here
|
| 503 |
$schema->storage->txn_rollback; |
503 |
$schema->storage->txn_rollback; |
| 504 |
}; |
504 |
}; |
| 505 |
|
505 |
|
| 506 |
subtest 'get_marc_components() tests' => sub { |
506 |
subtest 'get_marc_analytics() tests' => sub { |
| 507 |
|
507 |
|
| 508 |
plan tests => 3; |
508 |
plan tests => 3; |
| 509 |
|
509 |
|
|
Lines 515-527
subtest 'get_marc_components() tests' => sub {
Link Here
|
| 515 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
515 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
| 516 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
516 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
| 517 |
|
517 |
|
| 518 |
my @components = $host_biblio->get_marc_components; |
518 |
my @components = $host_biblio->get_marc_analytics; |
| 519 |
is( ref(\@components), 'ARRAY', 'Return type is correct' ); |
519 |
is( ref(\@components), 'ARRAY', 'Return type is correct' ); |
| 520 |
|
520 |
|
| 521 |
is_deeply( |
521 |
is_deeply( |
| 522 |
[@components], |
522 |
[@components], |
| 523 |
[()], |
523 |
[[]], |
| 524 |
'->get_marc_components returns an empty ARRAY' |
524 |
'->get_marc_analytics returns an empty ARRAY' |
| 525 |
); |
525 |
); |
| 526 |
|
526 |
|
| 527 |
$search_mod->unmock( 'simple_search_compat'); |
527 |
$search_mod->unmock( 'simple_search_compat'); |
|
Lines 529-543
subtest 'get_marc_components() tests' => sub {
Link Here
|
| 529 |
my $component_record = component_record1()->as_xml(); |
529 |
my $component_record = component_record1()->as_xml(); |
| 530 |
|
530 |
|
| 531 |
is_deeply( |
531 |
is_deeply( |
| 532 |
$host_biblio->get_marc_components, |
532 |
$host_biblio->get_marc_analytics, |
| 533 |
[($component_record)], |
533 |
[($component_record)], |
| 534 |
'->get_marc_components returns the related component part record' |
534 |
'->get_marc_analytics returns the related component part record' |
| 535 |
); |
535 |
); |
| 536 |
$search_mod->unmock( 'simple_search_compat'); |
536 |
$search_mod->unmock( 'simple_search_compat'); |
| 537 |
|
537 |
|
| 538 |
$schema->storage->txn_rollback; |
538 |
$schema->storage->txn_rollback; |
| 539 |
}; |
539 |
}; |
| 540 |
|
540 |
|
|
|
541 |
subtest 'get_analytics_query' => sub { |
| 542 |
plan tests => 3; |
| 543 |
|
| 544 |
my $biblio = $builder->build_sample_biblio(); |
| 545 |
my $biblionumber = $biblio->biblionumber; |
| 546 |
my $record = $biblio->metadata->record; |
| 547 |
|
| 548 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
| 549 |
is($biblio->get_analytics_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); |
| 550 |
|
| 551 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
| 552 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
| 553 |
$record->append_fields($marc_001_field); |
| 554 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 555 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 556 |
|
| 557 |
is($biblio->get_analytics_query, "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode"); |
| 558 |
|
| 559 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
| 560 |
$record->append_fields($marc_003_field); |
| 561 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 562 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 563 |
|
| 564 |
is($biblio->get_analytics_query, "((rcn:$biblionumber AND cni:OSt) OR rcn:OSt $biblionumber) AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled with MarcOrgCode"); |
| 565 |
}; |
| 566 |
|
| 541 |
subtest 'orders() and active_orders() tests' => sub { |
567 |
subtest 'orders() and active_orders() tests' => sub { |
| 542 |
|
568 |
|
| 543 |
plan tests => 5; |
569 |
plan tests => 5; |
| 544 |
- |
|
|