Bug 24062: Make sure TestBuilder will stop generate X or other invalid category's types
To make sure this kind of random failures will not appear in a future we are going to fix it at TestBuilder level. Test plan: prove t/db_dependent/TestBuilder.t and confirm it returns green You could also only apply the tests against master, run them several times and confirm that they fail most of the time. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
cbe22553fe
commit
fda209ca50
|
|
@ -339,12 +339,23 @@ subtest 'Date handling' => sub {
|
|||
};
|
||||
|
||||
subtest 'Default values' => sub {
|
||||
plan tests => 2;
|
||||
plan tests => 3;
|
||||
|
||||
$builder = t::lib::TestBuilder->new;
|
||||
my $item = $builder->build( { source => 'Item' } );
|
||||
is( $item->{more_subfields_xml}, undef, 'This xml field should be undef' );
|
||||
$item = $builder->build( { source => 'Item', value => { more_subfields_xml => 'some xml' } } );
|
||||
is( $item->{more_subfields_xml}, 'some xml', 'Default should not overwrite assigned value' );
|
||||
|
||||
subtest 'generated dynamically (coderef)' => sub {
|
||||
plan tests => 2;
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
like( $patron->category->category_type, qr{^(A|C|S|I|P|)$}, );
|
||||
|
||||
my $patron_category_X = $builder->build_object({ class => 'Koha::Patron::Categories', value => { category_type => 'X' } });
|
||||
$patron = $builder->build_object({ class => 'Koha::Patrons', value => {categorycode => $patron_category_X->categorycode} });
|
||||
is( $patron->category->category_type, 'X', );
|
||||
};
|
||||
};
|
||||
|
||||
subtest 'build_object() tests' => sub {
|
||||
|
|
|
|||
|
|
@ -401,7 +401,9 @@ sub _buildColumnValue {
|
|||
}
|
||||
push @$retvalue, $value->{$col_name};
|
||||
} elsif( exists $self->{default_values}{$source}{$col_name} ) {
|
||||
push @$retvalue, $self->{default_values}{$source}{$col_name};
|
||||
my $v = $self->{default_values}{$source}{$col_name};
|
||||
$v = &$v() if ref($v) eq 'CODE';
|
||||
push @$retvalue, $v;
|
||||
} else {
|
||||
my $data_type = $col_info->{data_type};
|
||||
$data_type =~ s| |_|;
|
||||
|
|
@ -550,6 +552,8 @@ sub _gen_default_values {
|
|||
Category => {
|
||||
enrolmentfee => 0,
|
||||
reservefee => 0,
|
||||
# Not X, used for statistics
|
||||
category_type => sub { return [ qw( A C S I P ) ]->[int(rand(5))] },
|
||||
},
|
||||
Itemtype => {
|
||||
rentalcharge => 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue