Reorganize documentation an order of tests.

Make this a little easier to find.
This commit is contained in:
Bradley M. Kuhn 2015-12-09 19:38:22 -08:00
parent b0d7639bc3
commit a1df7fc544

View file

@ -10,18 +10,33 @@ use Test::Exception;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
BEGIN { use_ok('Supporters') };
=pod =pod
Initial tests to verify creation of objects Supporters.t is the basic unit tests for Supporters.pm. It tests the
following things:
=over
=item use command for the module.
=cut =cut
BEGIN { use_ok('Supporters') };
require 't/CreateTestDB.pl'; require 't/CreateTestDB.pl';
my $dbh = get_test_dbh(); my $dbh = get_test_dbh();
=item Public-facing methods of the module, as follows:
=over
=item new
=cut
my $sp = new Supporters($dbh, "testcmd"); my $sp = new Supporters($dbh, "testcmd");
is($dbh, $sp->dbh(), "new: verify dbh set"); is($dbh, $sp->dbh(), "new: verify dbh set");
@ -30,7 +45,7 @@ is("testcmd", $sp->ledgerCmd(), "new: verify ledgerCmd set");
=pod =pod
Test adding a supporter to the database. =item addSupporter
=cut =cut
@ -55,14 +70,22 @@ lives_ok { $id2 = $sp->addSupporter({ display_name => "Donald Drapper",
ok( (looks_like_number($id2) and $id2 > $id1), ok( (looks_like_number($id2) and $id2 > $id1),
"addSupporter: add works with public_ack set to true and a display_name given"); "addSupporter: add works with public_ack set to true and a display_name given");
=pod =item addEmailAddress
Tests for internal methods: =cut
dies_ok { $sp->_addEmailAdress(undef, 'drapper@example.org', 'paypal'); }
"_addEmailAdress: dies for undefined id";
dies_ok { $sp->_addEmailAdress("String", 'drapper@example.org', 'paypal'); }
"_addEmailAdress: dies for non-numeric id";
=back
=item Internal methods used only by the module itself.
=over =over
=item _verifyId
=item _verifyId tests
=cut =cut
@ -74,15 +97,12 @@ dies_ok { $sp->_verifyId("String") } "_verifyId: dies for non-numeric id";
# This is a hacky way to test this; but should work # This is a hacky way to test this; but should work
ok(not ($sp->_verifyId($id2 + 10)), "_verifyId: non-existent id is not found"); ok(not ($sp->_verifyId($id2 + 10)), "_verifyId: non-existent id is not found");
dies_ok { $sp->_addEmailAdress(undef, 'drapper@example.org', 'paypal'); }
"_addEmailAdress: dies for undefined id";
dies_ok { $sp->_addEmailAdress("String", 'drapper@example.org', 'paypal'); }
"_addEmailAdress: dies for non-numeric id";
=pod =pod
=back =back
=back
=cut =cut
$dbh->disconnect(); $dbh->disconnect();