From edb334e31b7b1c5e6acec7d8d8f7ffcc3a054f85 Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Wed, 9 Dec 2015 11:31:12 +0100 Subject: [PATCH] Bug 15339: TestBuilder warnings (tests) Makes TestBuilder::build() alert the user when unreognized parameters are passed, which happens when the user supplies the column values directly, forgetting the 'value' hash. This patch contains the tests that doubles as a demonstration of the kind of error the patch is intended to prevent. Sponsored-By: Halland County Library --- t/db_dependent/TestBuilder.t | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t index 638d2ef..74b5988 100644 --- a/t/db_dependent/TestBuilder.t +++ b/t/db_dependent/TestBuilder.t @@ -19,7 +19,8 @@ use Modern::Perl; -use Test::More tests => 42; +use Test::More tests => 44; +use Test::Warn; use Koha::Database; @@ -280,6 +281,23 @@ subtest 'Auto-increment values tests' => sub { }; +# Test to make sure build() warns user of unknown parameters. +warnings_are { + $builder->build({ + source => 'Branch', + values => { + branchcode => 'BRANCH_1' + } + }) +} [], "No warnings on correct use"; + +warnings_like { + $builder->build({ + source => 'Branch', + branchcode => 'BRANCH_2' # This is wrong! + }) +} qr/unknown param/i, "Carp unknown parameters"; + $schema->storage->txn_rollback; 1; -- 2.1.4