Bug 17726: TestBuilder - Add default values
The items.more_subfields_xml is set to random data (generated by TestBuilder), and so GetMarcBiblio does not manage to embed items (if needed). The error is: :1: parser error : Start tag expected, '<' not found More precisely it explodes in C4::Items::_parse_unlinked_item_subfields_from_xml when MARC::Record->new_from_xml is called with an invalid xml This patch adds a default values mechanism to TestBuilder to avoid modifying all the existing calls. Test plan: Set SearchEngine to ElasticSearch prove t/db_dependent/Circulation.pl should return green with this patch Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
63f7cbc777
commit
41358176e1
2 changed files with 25 additions and 1 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 10;
|
||||
use Test::More tests => 11;
|
||||
use Test::Warn;
|
||||
use Data::Dumper qw(Dumper);
|
||||
|
||||
|
@ -332,6 +332,15 @@ subtest 'Date handling' => sub {
|
|||
|
||||
};
|
||||
|
||||
subtest 'Default values' => sub {
|
||||
plan tests => 2;
|
||||
$builder = t::lib::TestBuilder->new;
|
||||
my $item = $builder->build( { source => 'Item' } );
|
||||
is( $item->{more_subfields_xml}, undef );
|
||||
$item = $builder->build( { source => 'Item', value => { more_subfields_xml => 'some xml' } } );
|
||||
is( $item->{more_subfields_xml}, 'some xml' );
|
||||
};
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
1;
|
||||
|
|
|
@ -13,6 +13,7 @@ sub new {
|
|||
$self->schema->storage->sql_maker->quote_char('`');
|
||||
|
||||
$self->{gen_type} = _gen_type();
|
||||
$self->{default_values} = _gen_default_values();
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -290,6 +291,8 @@ sub _buildColumnValue {
|
|||
return;
|
||||
}
|
||||
push @$retvalue, $value->{$col_name};
|
||||
} elsif( exists $self->{default_values}{$source}{$col_name} ) {
|
||||
push @$retvalue, $self->{default_values}{$source}{$col_name};
|
||||
} else {
|
||||
my $data_type = $col_info->{data_type};
|
||||
$data_type =~ s| |_|;
|
||||
|
@ -414,6 +417,18 @@ sub _gen_blob {
|
|||
return 'b';
|
||||
}
|
||||
|
||||
sub _gen_default_values {
|
||||
my ($self) = @_;
|
||||
return {
|
||||
Item => {
|
||||
more_subfields_xml => undef,
|
||||
},
|
||||
Biblioitem => {
|
||||
marcxml => undef,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
||||
t::lib::TestBuilder.pm - Koha module to create test records
|
||||
|
|
Loading…
Reference in a new issue