Lines 507-513
subtest 'suggestions() tests' => sub {
Link Here
|
507 |
$schema->storage->txn_rollback; |
507 |
$schema->storage->txn_rollback; |
508 |
}; |
508 |
}; |
509 |
|
509 |
|
510 |
subtest 'get_marc_analytics() tests' => sub { |
510 |
subtest 'get_marc_components() tests' => sub { |
511 |
|
511 |
|
512 |
plan tests => 3; |
512 |
plan tests => 3; |
513 |
|
513 |
|
Lines 519-531
subtest 'get_marc_analytics() tests' => sub {
Link Here
|
519 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
519 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
520 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
520 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
521 |
|
521 |
|
522 |
my @components = $host_biblio->get_marc_analytics; |
522 |
my @components = $host_biblio->get_marc_components; |
523 |
is( ref(\@components), 'ARRAY', 'Return type is correct' ); |
523 |
is( ref(\@components), 'ARRAY', 'Return type is correct' ); |
524 |
|
524 |
|
525 |
is_deeply( |
525 |
is_deeply( |
526 |
[@components], |
526 |
[@components], |
527 |
[[]], |
527 |
[[]], |
528 |
'->get_marc_analytics returns an empty ARRAY' |
528 |
'->get_marc_components returns an empty ARRAY' |
529 |
); |
529 |
); |
530 |
|
530 |
|
531 |
$search_mod->unmock( 'simple_search_compat'); |
531 |
$search_mod->unmock( 'simple_search_compat'); |
Lines 533-548
subtest 'get_marc_analytics() tests' => sub {
Link Here
|
533 |
my $component_record = component_record1()->as_xml(); |
533 |
my $component_record = component_record1()->as_xml(); |
534 |
|
534 |
|
535 |
is_deeply( |
535 |
is_deeply( |
536 |
$host_biblio->get_marc_analytics, |
536 |
$host_biblio->get_marc_components, |
537 |
[($component_record)], |
537 |
[($component_record)], |
538 |
'->get_marc_analytics returns the related component part record' |
538 |
'->get_marc_components returns the related component part record' |
539 |
); |
539 |
); |
540 |
$search_mod->unmock( 'simple_search_compat'); |
540 |
$search_mod->unmock( 'simple_search_compat'); |
541 |
|
541 |
|
542 |
$schema->storage->txn_rollback; |
542 |
$schema->storage->txn_rollback; |
543 |
}; |
543 |
}; |
544 |
|
544 |
|
545 |
subtest 'get_analytics_query' => sub { |
545 |
subtest 'get_components_query' => sub { |
546 |
plan tests => 3; |
546 |
plan tests => 3; |
547 |
|
547 |
|
548 |
my $biblio = $builder->build_sample_biblio(); |
548 |
my $biblio = $builder->build_sample_biblio(); |
Lines 550-556
subtest 'get_analytics_query' => sub {
Link Here
|
550 |
my $record = $biblio->metadata->record; |
550 |
my $record = $biblio->metadata->record; |
551 |
|
551 |
|
552 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
552 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
553 |
is($biblio->get_analytics_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); |
553 |
is($biblio->get_components_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); |
554 |
|
554 |
|
555 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
555 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
556 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
556 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
Lines 558-571
subtest 'get_analytics_query' => sub {
Link Here
|
558 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
558 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
559 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
559 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
560 |
|
560 |
|
561 |
is($biblio->get_analytics_query, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled without MarcOrgCode"); |
561 |
is($biblio->get_components_query, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled without MarcOrgCode"); |
562 |
|
562 |
|
563 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
563 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
564 |
$record->append_fields($marc_003_field); |
564 |
$record->append_fields($marc_003_field); |
565 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
565 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
566 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
566 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
567 |
|
567 |
|
568 |
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"); |
568 |
is($biblio->get_components_query, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled with MarcOrgCode"); |
569 |
}; |
569 |
}; |
570 |
|
570 |
|
571 |
subtest 'orders() and active_orders() tests' => sub { |
571 |
subtest 'orders() and active_orders() tests' => sub { |
572 |
- |
|
|