|
Lines 562-601
subtest 'get_marc_components() tests' => sub {
Link Here
|
| 562 |
}; |
562 |
}; |
| 563 |
|
563 |
|
| 564 |
subtest 'get_components_query' => sub { |
564 |
subtest 'get_components_query' => sub { |
| 565 |
plan tests => 6; |
565 |
plan tests => 12; |
| 566 |
|
566 |
|
| 567 |
my $biblio = $builder->build_sample_biblio(); |
567 |
my $biblio = $builder->build_sample_biblio(); |
| 568 |
my $biblionumber = $biblio->biblionumber; |
568 |
my $biblionumber = $biblio->biblionumber; |
| 569 |
my $record = $biblio->metadata->record; |
569 |
my $record = $biblio->metadata->record; |
| 570 |
|
570 |
|
| 571 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
571 |
foreach my $engine ('Zebra','Elasticsearch'){ |
| 572 |
t::lib::Mocks::mock_preference( 'ComponentSortField', 'author' ); |
572 |
t::lib::Mocks::mock_preference( 'SearchEngine', $engine ); |
| 573 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'za' ); |
573 |
|
| 574 |
my ( $comp_q, $comp_s ) = $biblio->get_components_query; |
574 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
| 575 |
is($comp_q, 'Host-item:("Some boring read")', "UseControlNumber disabled"); |
575 |
t::lib::Mocks::mock_preference( 'ComponentSortField', 'author' ); |
| 576 |
is($comp_s, "author_za", "UseControlNumber disabled sort is correct"); |
576 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'za' ); |
| 577 |
|
577 |
my ( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query; |
| 578 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
578 |
is($comp_query_str, 'Host-item:("Some boring read")', "$engine: UseControlNumber disabled"); |
| 579 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'az' ); |
579 |
is($comp_sort, "author_za", "$engine: UseControlNumber disabled sort is correct"); |
| 580 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
580 |
|
| 581 |
$record->append_fields($marc_001_field); |
581 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
| 582 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
582 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'az' ); |
| 583 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
583 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
| 584 |
|
584 |
$record->append_fields($marc_001_field); |
| 585 |
( $comp_q, $comp_s ) = $biblio->get_components_query; |
585 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 586 |
is($comp_q, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled without MarcOrgCode"); |
586 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 587 |
is($comp_s, "author_az", "UseControlNumber enabled without MarcOrgCode sort is correct"); |
587 |
|
| 588 |
|
588 |
( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query; |
| 589 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
589 |
is($comp_query_str, "(rcn:$biblionumber AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled without MarcOrgCode"); |
| 590 |
$record->append_fields($marc_003_field); |
590 |
is($comp_sort, "author_az", "$engine: UseControlNumber enabled without MarcOrgCode sort is correct"); |
| 591 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
591 |
|
| 592 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
592 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
| 593 |
|
593 |
$record->append_fields($marc_003_field); |
| 594 |
t::lib::Mocks::mock_preference( 'ComponentSortField', 'title' ); |
594 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 595 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'asc' ); |
595 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
| 596 |
( $comp_q, $comp_s ) = $biblio->get_components_query; |
596 |
|
| 597 |
is($comp_q, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled with MarcOrgCode"); |
597 |
t::lib::Mocks::mock_preference( 'ComponentSortField', 'title' ); |
| 598 |
is($comp_s, "title_asc", "UseControlNumber enabled with MarcOrgCode sort if correct"); |
598 |
t::lib::Mocks::mock_preference( 'ComponentSortOrder', 'asc' ); |
|
|
599 |
( $comp_query, $comp_query_str, $comp_sort ) = $biblio->get_components_query; |
| 600 |
is($comp_query_str, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "$engine: UseControlNumber enabled with MarcOrgCode"); |
| 601 |
is($comp_sort, "title_asc", "$engine: UseControlNumber enabled with MarcOrgCode sort if correct"); |
| 602 |
$record->delete_field($marc_003_field); |
| 603 |
} |
| 599 |
}; |
604 |
}; |
| 600 |
|
605 |
|
| 601 |
subtest 'orders() and active_orders() tests' => sub { |
606 |
subtest 'orders() and active_orders() tests' => sub { |
| 602 |
- |
|
|