diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 5e2822a..5d3b545 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -43,6 +43,12 @@ sub dbh ($) { sub ledgerCmd ($) { return $_[0]->{ledgerCmd}; } +###################################################################### +sub addSupporter ($) { + my($sp) = @_; + + die "ledger_entity_id required" unless defined $sp->{ledger_entity_id}; +} 1; diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 0414d69..c6951db 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -6,7 +6,9 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 4; +use Test::Exception; + BEGIN { use_ok('Supporters') }; =pod @@ -24,5 +26,14 @@ my $sp = new Supporters($dbh, "testcmd"); is($dbh, $sp->dbh()); is("testcmd", $sp->ledgerCmd()); + +=pod + +Test adding a supporter to the database. + +=cut + +dies_ok { $sp->addSupporter({}) } "ledger_entity_id required"; + $dbh->disconnect();