Lines 60-66
SKIP: {
Link Here
|
60 |
|
60 |
|
61 |
subtest '_convert_marc_to_json() tests' => sub { |
61 |
subtest '_convert_marc_to_json() tests' => sub { |
62 |
|
62 |
|
63 |
plan tests => 2; |
63 |
plan tests => 4; |
64 |
|
64 |
|
65 |
$schema->storage->txn_begin; |
65 |
$schema->storage->txn_begin; |
66 |
|
66 |
|
Lines 113-124
subtest '_convert_marc_to_json() tests' => sub {
Link Here
|
113 |
MARC::Field->new( '110', '', '', 'a' => 'Corp Author' ), |
113 |
MARC::Field->new( '110', '', '', 'a' => 'Corp Author' ), |
114 |
MARC::Field->new( '245', '', '', 'a' => 'Title' ), |
114 |
MARC::Field->new( '245', '', '', 'a' => 'Title' ), |
115 |
); |
115 |
); |
116 |
my @records = ( $marc_record ); |
116 |
my $marc_record_2 = MARC::Record->new(); |
117 |
|
117 |
$marc_record_2->append_fields( |
118 |
my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' }); |
118 |
MARC::Field->new( '001', '1234567' ), |
119 |
my $conv = $importer->_convert_marc_to_json( \@records )->next(); |
119 |
MARC::Field->new( '020', '', '', 'a' => '1234567890123' ), |
120 |
is( $conv->{author}[0][0], "Author", "First mapped author should be 100a"); |
120 |
MARC::Field->new( '100', '', '', 'a' => 'Author' ), |
121 |
is( $conv->{author}[1][0], "Corp Author", "Second mapped author should be 110a"); |
121 |
MARC::Field->new( '245', '', '', 'a' => 'Title' ), |
|
|
122 |
); |
123 |
my @records = ( $marc_record, $marc_record_2 ); |
124 |
|
125 |
my $importer = Koha::SearchEngine::Elasticsearch::Indexer->new({ index => 'biblios' })->_convert_marc_to_json( \@records ); |
126 |
my $conv = $importer->next(); |
127 |
warn Data::Dumper::Dumper( $conv ); |
128 |
is( $conv->{author}[0], "Author", "First mapped author should be 100a"); |
129 |
is( $conv->{author}[1], "Corp Author", "Second mapped author should be 110a"); |
130 |
|
131 |
$conv = $importer->next(); |
132 |
warn Data::Dumper::Dumper( $conv ); |
133 |
is( $conv->{author}[0], "Author", "First mapped author should be 100a"); |
134 |
is( scalar @{$conv->{author}} , 1, "We should map field only if exists, shouldn't add extra nulls"); |
122 |
|
135 |
|
123 |
$schema->storage->txn_rollback; |
136 |
$schema->storage->txn_rollback; |
124 |
}; |
137 |
}; |
125 |
- |
|
|