From fc22b9a3cc139656eedd6ebdb88739c012d175fb Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 6 Dec 2015 18:56:59 -0800 Subject: [PATCH] Begin writing addSupporter method. ledger_entity_id is required. --- Supporters/lib/Supporters.pm | 6 ++++++ Supporters/t/Supporters.t | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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();