Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use Encode; |
19 |
use Encode; |
20 |
|
20 |
|
21 |
use Test::More tests => 8; |
21 |
use Test::More tests => 9; |
|
|
22 |
use Test::NoWarnings; |
23 |
use Test::Warn; |
22 |
use Test::Exception; |
24 |
use Test::Exception; |
23 |
|
25 |
|
24 |
use t::lib::Mocks; |
26 |
use t::lib::Mocks; |
Lines 209-215
subtest 'get_elasticsearch_mappings() tests' => sub {
Link Here
|
209 |
|
211 |
|
210 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
212 |
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests' => sub { |
211 |
|
213 |
|
212 |
plan tests => 70; |
214 |
plan tests => 71; |
213 |
|
215 |
|
214 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
216 |
t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); |
215 |
t::lib::Mocks::mock_preference( 'ElasticsearchMARCFormat', 'base64ISO2709' ); |
217 |
t::lib::Mocks::mock_preference( 'ElasticsearchMARCFormat', 'base64ISO2709' ); |
Lines 851-857
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () tests'
Link Here
|
851 |
MARC::Field->new( '999', '', '', c => '1234567' ), |
853 |
MARC::Field->new( '999', '', '', c => '1234567' ), |
852 |
); |
854 |
); |
853 |
|
855 |
|
854 |
$docs = $see->marc_records_to_documents( [$marc_record_with_large_field] ); |
856 |
warning_is { |
|
|
857 |
$docs = $see->marc_records_to_documents( [$marc_record_with_large_field] ); |
858 |
} |
859 |
"Warnings encountered while roundtripping a MARC record to/from USMARC. Failing over to MARCXML."; |
855 |
|
860 |
|
856 |
subtest '_process_mappings() split tests' => sub { |
861 |
subtest '_process_mappings() split tests' => sub { |
857 |
|
862 |
|
Lines 1225-1245
subtest 'marc_records_to_documents should set the "available" field' => sub {
Link Here
|
1225 |
# sort_fields will call this and use the actual db values unless we call it first |
1230 |
# sort_fields will call this and use the actual db values unless we call it first |
1226 |
$see->get_elasticsearch_mappings(); |
1231 |
$see->get_elasticsearch_mappings(); |
1227 |
|
1232 |
|
1228 |
my $marc_record_1 = MARC::Record->new(); |
1233 |
my $builder = t::lib::TestBuilder->new; |
1229 |
$marc_record_1->leader(' cam 22 a 4500'); |
1234 |
my $biblio = $builder->build_sample_biblio; |
1230 |
$marc_record_1->append_fields( |
1235 |
my $marc_record_1 = $biblio->metadata->record; |
1231 |
MARC::Field->new( '245', '', '', a => 'Title' ), |
|
|
1232 |
); |
1233 |
my ($biblionumber) = C4::Biblio::AddBiblio( $marc_record_1, '' ); |
1234 |
|
1236 |
|
1235 |
my $docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1237 |
my $docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1236 |
is_deeply( $docs->[0]->{available}, \0, 'a biblio without items is not available' ); |
1238 |
is_deeply( $docs->[0]->{available}, \0, 'a biblio without items is not available' ); |
1237 |
|
1239 |
|
1238 |
my $item = Koha::Item->new( |
1240 |
my $item = $builder->build_sample_item( |
1239 |
{ |
1241 |
{ |
1240 |
biblionumber => $biblionumber, |
1242 |
biblionumber => $biblio->biblionumber, |
1241 |
} |
1243 |
} |
1242 |
)->store(); |
1244 |
); |
1243 |
|
1245 |
|
1244 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1246 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1245 |
is_deeply( $docs->[0]->{available}, \1, 'a biblio with one item that has no particular status is available' ); |
1247 |
is_deeply( $docs->[0]->{available}, \1, 'a biblio with one item that has no particular status is available' ); |
Lines 1264-1274
subtest 'marc_records_to_documents should set the "available" field' => sub {
Link Here
|
1264 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1266 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1265 |
is_deeply( $docs->[0]->{available}, \1, 'a biblio with one item that is damaged is available' ); |
1267 |
is_deeply( $docs->[0]->{available}, \1, 'a biblio with one item that is damaged is available' ); |
1266 |
|
1268 |
|
1267 |
my $item2 = Koha::Item->new( |
1269 |
my $item2 = $builder->build_sample_item( |
1268 |
{ |
1270 |
{ |
1269 |
biblionumber => $biblionumber, |
1271 |
biblionumber => $biblio->biblionumber, |
1270 |
} |
1272 |
} |
1271 |
)->store(); |
1273 |
); |
1272 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1274 |
$docs = $see->marc_records_to_documents( [$marc_record_1] ); |
1273 |
is_deeply( |
1275 |
is_deeply( |
1274 |
$docs->[0]->{available}, \1, |
1276 |
$docs->[0]->{available}, \1, |
1275 |
- |
|
|