|
Lines 17-25
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 17; |
20 |
use Test::More tests => 18; |
| 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::Caches; |
24 |
use Koha::Caches; |
| 25 |
use Koha::Acquisition::Orders; |
25 |
use Koha::Acquisition::Orders; |
|
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_components() tests' => sub { |
510 |
subtest 'get_marc_analytics() tests' => sub { |
| 511 |
|
511 |
|
| 512 |
plan tests => 3; |
512 |
plan tests => 3; |
| 513 |
|
513 |
|
|
Lines 519-531
subtest 'get_marc_components() 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_components; |
522 |
my @components = $host_biblio->get_marc_analytics; |
| 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_components returns an empty ARRAY' |
528 |
'->get_marc_analytics returns an empty ARRAY' |
| 529 |
); |
529 |
); |
| 530 |
|
530 |
|
| 531 |
$search_mod->unmock( 'simple_search_compat'); |
531 |
$search_mod->unmock( 'simple_search_compat'); |
|
Lines 533-547
subtest 'get_marc_components() 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_components, |
536 |
$host_biblio->get_marc_analytics, |
| 537 |
[($component_record)], |
537 |
[($component_record)], |
| 538 |
'->get_marc_components returns the related component part record' |
538 |
'->get_marc_analytics 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 { |
| 546 |
plan tests => 3; |
| 547 |
|
| 548 |
my $biblio = $builder->build_sample_biblio(); |
| 549 |
my $biblionumber = $biblio->biblionumber; |
| 550 |
my $record = $biblio->metadata->record; |
| 551 |
|
| 552 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
| 553 |
is($biblio->get_analytics_query, "Host-item:(Some boring read)", "UseControlNumber disabled"); |
| 554 |
|
| 555 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
| 556 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
| 557 |
$record->append_fields($marc_001_field); |
| 558 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 559 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 560 |
|
| 561 |
is($biblio->get_analytics_query, "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode"); |
| 562 |
|
| 563 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
| 564 |
$record->append_fields($marc_003_field); |
| 565 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 566 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 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"); |
| 569 |
}; |
| 570 |
|
| 545 |
subtest 'orders() and active_orders() tests' => sub { |
571 |
subtest 'orders() and active_orders() tests' => sub { |
| 546 |
|
572 |
|
| 547 |
plan tests => 5; |
573 |
plan tests => 5; |
| 548 |
- |
|
|