diff --git a/Koha/ERM/EUsage/UsageDataProvider.pm b/Koha/ERM/EUsage/UsageDataProvider.pm index ab9f314c80..5e04714bb4 100644 --- a/Koha/ERM/EUsage/UsageDataProvider.pm +++ b/Koha/ERM/EUsage/UsageDataProvider.pm @@ -300,10 +300,10 @@ sub test_connection { my $status; if ( ref($result) eq 'ARRAY' ) { for my $r (@$result) { - $status = $r->{Service_Active}; + $status = $r->{Service_Active} // $r->{ServiceActive}; } } else { - $status = $result->{Service_Active}; + $status = $result->{Service_Active} // $result->{ServiceActive}; } if ($status) { diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 79522b4f27..a2fd4dd0db 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -793,8 +793,9 @@ sub marc_records_to_documents { my $usmarc_record = $record->as_usmarc(); #NOTE: Try to round-trip the record to prove it will work for retrieval after searching - my $decoded_usmarc_record = MARC::Record->new_from_usmarc($usmarc_record); - if ( $decoded_usmarc_record->warnings() ) { + my $decoded_usmarc_record; + eval { $decoded_usmarc_record = MARC::Record->new_from_usmarc($usmarc_record); }; + if ( $@ || $decoded_usmarc_record->warnings() ) { #NOTE: We override the warnings since they're many and misleading @warnings = ( diff --git a/Makefile.PL b/Makefile.PL index 62062d96b2..33d0b0c1b3 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -675,6 +675,7 @@ $file_map->{'koha-tmpl/intranet-tmpl/prog/css/mainpage.css'} = 'blib/INTRANET_TM $file_map->{'koha-tmpl/intranet-tmpl/prog/css/staff-global.css'} = 'blib/INTRANET_TMPL_DIR/prog/css/staff-global.css'; $file_map->{'koha-tmpl/intranet-tmpl/prog/js/vue/dist/erm.js'} = 'blib/INTRANET_TMPL_DIR/prog/js/vue/dist/erm.js'; $file_map->{'koha-tmpl/intranet-tmpl/prog/js/vue/dist/preservation.js'} = 'blib/INTRANET_TMPL_DIR/prog/js/vue/dist/preservation.js'; +$file_map->{'koha-tmpl/intranet-tmpl/prog/js/vue/dist/admin/record_sources.js'} = 'blib/INTRANET_TMPL_DIR/prog/js/vue/dist/admin/record_sources.js'; #OPAC_TMPL_DIR $file_map->{'koha-tmpl/opac-tmpl/bootstrap/css/opac.css'} = 'blib/OPAC_TMPL_DIR/bootstrap/css/opac.css'; $file_map->{'koha-tmpl/opac-tmpl/bootstrap/css/opac-rtl.css'} = 'blib/OPAC_TMPL_DIR/bootstrap/css/opac-rtl.css'; diff --git a/t/db_dependent/Koha/ERM/EUsage/UsageDataProvider.t b/t/db_dependent/Koha/ERM/EUsage/UsageDataProvider.t index 2513b6f247..941bfe351d 100755 --- a/t/db_dependent/Koha/ERM/EUsage/UsageDataProvider.t +++ b/t/db_dependent/Koha/ERM/EUsage/UsageDataProvider.t @@ -17,10 +17,12 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; use Koha::ERM::EUsage::UsageDataProvider; use Koha::Database; +use Test::MockModule; +use Test::MockObject; use t::lib::TestBuilder; @@ -108,3 +110,53 @@ subtest '_build_url_query' => sub { $schema->storage->txn_rollback; }; + +subtest 'test_connection() tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $ua = Test::MockModule->new('LWP::UserAgent'); + $ua->mock( + 'simple_request', + sub { + my $response = Test::MockObject->new(); + + $response->mock( + 'code', + sub { + return 200; + } + ); + $response->mock( + 'is_error', + sub { + return 0; + } + ); + $response->mock( + 'is_redirect', + sub { + return 0; + } + ); + $response->mock( + 'decoded_content', + sub { + return + '{"Description":"COUNTER Usage Reports for Test platform.","ServiceActive":true,"RegistryURL":"https://www.whatever.com"}'; + } + ); + $response->{_rc} = 200; + return $response; + } + ); + + my $usage_data_provider = $builder->build_object( + { class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); + + is( $usage_data_provider->test_connection, 1 ); + + $schema->storage->txn_rollback; +}; diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t index 24159799f8..4a8cf9c41a 100755 --- a/t/db_dependent/Koha/SearchEngine/Elasticsearch.t +++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch.t @@ -16,6 +16,7 @@ # along with Koha; if not, see . use Modern::Perl; +use Encode; use Test::More tests => 8; use Test::Exception; @@ -680,7 +681,7 @@ subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' MARC::Field->new('999', '', '', c => '1234567'), ); - my $item_field = MARC::Field->new('952', '', '', o => '123456789123456789123456789', p => '123456789', z => 'test'); + my $item_field = MARC::Field->new('952', '', '', o => '123456789123456789123456789', p => '123456789', z => Encode::decode('UTF-8','To naprawdę bardzo długa notatka. Myślę, że będzie sprawiać kłopoty.')); my $items_count = 1638; while(--$items_count) { $large_marc_record->append_fields($item_field);