summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-21 20:45:17 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-11-21 20:45:17 +0000
commit695d7fd96eccb9a47b2bb44feaf475b65f3db138 (patch)
treed3c748e9ca9410f29e8d8a951ed34e27d90fcc8e /t
parent4162f3285a28eab5166dd31cc668da803a042aa7 (diff)
API tests now mostly work
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2412 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 't')
-rw-r--r--t/62-api.t32
1 files changed, 22 insertions, 10 deletions
diff --git a/t/62-api.t b/t/62-api.t
index a011660e..f05eb072 100644
--- a/t/62-api.t
+++ b/t/62-api.t
@@ -22,33 +22,45 @@ if (defined $ENV{LSMB_TEST_DB}){
do 't/data/62-request-data'; # Import test case hashes
-for (qw( admin.pl drafts.pl login.pl payment.pl
+for (qw( drafts.pl login.pl payment.pl
report.pl employee.pl menu.pl vendor.pl
- customer.pl inventory.pl migration.pl recon.pl
- vouchers.pl)){
-
- do "$_";
+ customer.pl inventory.pl vouchers.pl)
+ ){
+ ok(eval { require "scripts/$_" }, "Importing $_");
+ if ($@){
+ print STDERR "Error: $@\n";
+ }
} # Import new code namespaces
my $dbh = LedgerSMB::DBTest->connect("dbi:Pg:dbname=$ENV{PGDATABASE}", undef, undef);
-print scalar @$test_request_data ." test case scenarios defined";
-
for my $test (@$test_request_data){
if (lc $test->{_codebase} eq 'old'){
+ next; # skip old codebase tests for now
old_code_test::_load_script($test->{module});
- $old_code_test::form = new Form();
+ my $qtring = "$test->{module}?";
+ for $key (keys(%$test)){
+ if ($key !~ /^_/){
+ $qstring .= qq|$key=$test->{"$key"}&|;
+ }
+ }
+ $qstring =~ s/&$//;
+ $old_code_test::form = Form->new($qstring);
for (keys (%$test)){
$form->{$_} = $test->{$_};
}
- ok(eval ("old_code_test::$test->{action}()"),
+ is('old_code_test'->can($test->{action}), 0,
"$test->{_test_id}: Action Successful");
} else {
my $request = LedgerSMB->new();
$request->merge($test);
my $script = $test->{module};
+ $request->{dbh} = $dbh;
$script =~ s/\.pl$//;
- ok(eval "LedgerSMB::Scripts::$script::$request->{action}(\$request)");
+ is(ref "LedgerSMB::Scripts::$script"->can($request->{action}),
+ 'CODE',
+ "$test->{_test_id}: Action ($request->{action}) Defined");
+ ok("LedgerSMB::Scripts::$script"->can($request->{action})->($request), "$test->{_test_id}: Action Successful");
}
for (@{$api_test_cases->{"$test->{_test_id}"}}){
&$_;