@@ -, +, @@ not supplied --- t/db_dependent/TestBuilder.t | 14 +++++++++++--- t/lib/TestBuilder.pm | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) --- a/t/db_dependent/TestBuilder.t +++ a/t/db_dependent/TestBuilder.t @@ -36,12 +36,14 @@ our $builder; subtest 'Start with some trivial tests' => sub { - plan tests => 6; + plan tests => 7; $builder = t::lib::TestBuilder->new; isnt( $builder, undef, 'We got a builder' ); - is( $builder->build, undef, 'build without arguments returns undef' ); + my $data; + warning_like { my $data = $builder->build; } qr/.+/, 'Catch a warning'; + is( $data, undef, 'build without arguments returns undef' ); is( ref( $builder->schema ), 'Koha::Schema', 'check schema' ); is( ref( $builder->can('delete') ), 'CODE', 'found delete method' ); @@ -391,7 +393,7 @@ subtest 'build_object() tests' => sub { }; subtest '->build parameter' => sub { - plan tests => 2; + plan tests => 3; # Test to make sure build() warns user of unknown parameters. warnings_are { @@ -409,6 +411,12 @@ subtest '->build parameter' => sub { branchcode => 'BRANCH_2' # This is wrong! }) } qr/unknown param/i, "Carp unknown parameters"; + + warnings_like { + $builder->build({ + zource => 'Branch', # Intentional spelling error + }) + } qr/Source parameter not specified/, "Catch warning on missing source"; }; $schema->storage->txn_rollback; --- a/t/lib/TestBuilder.pm +++ a/t/lib/TestBuilder.pm @@ -86,7 +86,11 @@ sub build { # build returns a hash of column values for a created record, or undef # build does NOT update a record, or pass back values of an existing record my ($self, $params) = @_; - my $source = $params->{source} || return; + my $source = $params->{source}; + if( !$source ) { + carp "Source parameter not specified!"; + return; + } my $value = $params->{value}; my @unknowns = grep( !/^(source|value)$/, keys %{ $params }); --