Lines 18-23
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 18; |
20 |
use Test::More tests => 18; |
|
|
21 |
use Test::Warn; |
21 |
|
22 |
|
22 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
23 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
23 |
use Koha::Database; |
24 |
use Koha::Database; |
Lines 26-31
use Koha::Acquisition::Orders;
Link Here
|
26 |
use Koha::AuthorisedValueCategories; |
27 |
use Koha::AuthorisedValueCategories; |
27 |
use Koha::AuthorisedValues; |
28 |
use Koha::AuthorisedValues; |
28 |
use Koha::MarcSubfieldStructures; |
29 |
use Koha::MarcSubfieldStructures; |
|
|
30 |
use Koha::Exceptions::Exception; |
29 |
|
31 |
|
30 |
use MARC::Field; |
32 |
use MARC::Field; |
31 |
use MARC::Record; |
33 |
use MARC::Record; |
Lines 509-515
subtest 'suggestions() tests' => sub {
Link Here
|
509 |
|
511 |
|
510 |
subtest 'get_marc_components() tests' => sub { |
512 |
subtest 'get_marc_components() tests' => sub { |
511 |
|
513 |
|
512 |
plan tests => 3; |
514 |
plan tests => 5; |
513 |
|
515 |
|
514 |
$schema->storage->txn_begin; |
516 |
$schema->storage->txn_begin; |
515 |
|
517 |
|
Lines 519-530
subtest 'get_marc_components() tests' => sub {
Link Here
|
519 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
521 |
my $search_mod = Test::MockModule->new( 'Koha::SearchEngine::Zebra::Search' ); |
520 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
522 |
$search_mod->mock( 'simple_search_compat', \&search_component_record2 ); |
521 |
|
523 |
|
522 |
my @components = $host_biblio->get_marc_components; |
524 |
my $components = $host_biblio->get_marc_components; |
523 |
is( ref(\@components), 'ARRAY', 'Return type is correct' ); |
525 |
is( ref($components), 'ARRAY', 'Return type is correct' ); |
524 |
|
526 |
|
525 |
is_deeply( |
527 |
is_deeply( |
526 |
[@components], |
528 |
$components, |
527 |
[[]], |
529 |
[], |
528 |
'->get_marc_components returns an empty ARRAY' |
530 |
'->get_marc_components returns an empty ARRAY' |
529 |
); |
531 |
); |
530 |
|
532 |
|
Lines 534-544
subtest 'get_marc_components() tests' => sub {
Link Here
|
534 |
|
536 |
|
535 |
is_deeply( |
537 |
is_deeply( |
536 |
$host_biblio->get_marc_components, |
538 |
$host_biblio->get_marc_components, |
537 |
[($component_record)], |
539 |
[$component_record], |
538 |
'->get_marc_components returns the related component part record' |
540 |
'->get_marc_components returns the related component part record' |
539 |
); |
541 |
); |
540 |
$search_mod->unmock( 'simple_search_compat'); |
542 |
$search_mod->unmock( 'simple_search_compat'); |
541 |
|
543 |
|
|
|
544 |
$search_mod->mock( 'simple_search_compat', |
545 |
sub { Koha::Exceptions::Exception->throw("error searching analytics") } |
546 |
); |
547 |
warning_like { $components = $host_biblio->get_marc_components } |
548 |
qr{^Warning from simple_search_compat: 'error searching analytics'}; |
549 |
|
550 |
is_deeply( |
551 |
$host_biblio->messages, |
552 |
[ |
553 |
{ |
554 |
type => 'error', |
555 |
message => 'component_search', |
556 |
payload => "error searching analytics" |
557 |
} |
558 |
] |
559 |
); |
560 |
$search_mod->unmock( 'simple_search_compat'); |
561 |
|
542 |
$schema->storage->txn_rollback; |
562 |
$schema->storage->txn_rollback; |
543 |
}; |
563 |
}; |
544 |
|
564 |
|
545 |
- |
|
|