Correct arguments to method; add public_ack
This commit is contained in:
		
							parent
							
								
									afc15507fb
								
							
						
					
					
						commit
						3d672d1f68
					
				
					 2 changed files with 20 additions and 4 deletions
				
			
		|  | @ -44,10 +44,16 @@ sub ledgerCmd ($) { | |||
|   return $_[0]->{ledgerCmd}; | ||||
| } | ||||
| ###################################################################### | ||||
| sub addSupporter ($) { | ||||
|   my($sp) = @_; | ||||
| sub addSupporter ($$) { | ||||
|   my($this, $sp) = @_; | ||||
| 
 | ||||
|   die "ledger_entity_id required" unless defined $sp->{ledger_entity_id}; | ||||
| 
 | ||||
|   $sp->{public_ack} = 0 if not defined $sp->{public_ack}; | ||||
| 
 | ||||
|   if ($sp->{public_ack}) { | ||||
|     die "display_name required if public_ack requested" unless defined $sp->{display_name}; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| use strict; | ||||
| use warnings; | ||||
| 
 | ||||
| use Test::More tests => 4; | ||||
| use Test::More tests => 7; | ||||
| use Test::Exception; | ||||
| 
 | ||||
| BEGIN { use_ok('Supporters') }; | ||||
|  | @ -33,8 +33,18 @@ Test adding a supporter to the database. | |||
| 
 | ||||
| =cut | ||||
| 
 | ||||
| dies_ok(sub { $sp->addSupporter({}) }, "addSupporter: ledger_entity_id required"); | ||||
| dies_ok { $sp->addSupporter({}) } | ||||
|         "addSupporter: ledger_entity_id required"; | ||||
| 
 | ||||
| lives_ok { $sp->addSupporter({ ledger_entity_id => "Whitman-Dick" }) } | ||||
|          "addSupporter: minimal acceptable settings"; | ||||
| 
 | ||||
| dies_ok  { $sp->addSupporter({ public_ack => 1, ledger_entity_id => "Whitman-Dick" }) } | ||||
|          "addSupporter: display_name required"; | ||||
| 
 | ||||
| lives_ok { $sp->addSupporter({ display_name => "Donald Drapper", | ||||
|                                public_ack => 1, ledger_entity_id => "Whitman-Dick" }) } | ||||
|          "addSupporter: public_ack set to true with a display_name given"; | ||||
| 
 | ||||
| $dbh->disconnect(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Bradley M. Kuhn
						Bradley M. Kuhn