summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/62-api.t16
-rw-r--r--t/data/62-request-data36
2 files changed, 47 insertions, 5 deletions
diff --git a/t/62-api.t b/t/62-api.t
index f05eb072..740a1fcb 100644
--- a/t/62-api.t
+++ b/t/62-api.t
@@ -5,8 +5,6 @@ BEGIN {
use LedgerSMB::DBTest;
}
-our $api_test_cases = {
-};
if (defined $ENV{LSMB_TEST_DB}){
if (defined $ENV{LSMB_NEW_DB}){
@@ -56,14 +54,20 @@ for my $test (@$test_request_data){
$request->merge($test);
my $script = $test->{module};
$request->{dbh} = $dbh;
+ if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
+ $request->{_test_cases} =
+ $api_test_cases->{"$test->{_test_id}"};
+ }
+ delete $api_test_cases->{"$test->{_test_id}"};
$script =~ s/\.pl$//;
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}"}}){
- &$_;
+ if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
+ $request->{_test_cases} =
+ $api_test_cases->{"$test->{_test_id}"};
}
ok($dbh->rollback, "$test->{_test_id}: rollback");
}
@@ -72,6 +76,10 @@ package LedgerSMB::Template;
# Don't render templates. Just return so we can run tests on data structures.
sub render {
+ my ($self, $data) = @_;
+ if (ref $data->{_test_cases} eq 'CODE'){
+ $data->{_test_cases}($data);
+ }
return 1;
}
diff --git a/t/data/62-request-data b/t/data/62-request-data
index ae8c6d0e..e3c6108b 100644
--- a/t/data/62-request-data
+++ b/t/data/62-request-data
@@ -1,4 +1,4 @@
-
+use Test::More;
our $test_request_data = [
# AR/AP Transaction Screen Tests
{
@@ -49,8 +49,42 @@ our $test_request_data = [
'batch_type' => 'gl',
'module' => 'vouchers.pl',
},
+# {
+# '_test_id' => 'Payment print total',
+# '_codebase' => 'new',
+# 'action' => 'print',
+# 'module' => 'payment.pl',
+# 'account_class' => 1,
+# 'currency' => 'USD',
+# 'multiple' => 1,
+# 'format' =>
+#
+# },
];
+our $pre_test_subs = {};
+our $api_test_cases = {
+ 'AR Transaction Voucher Screen' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
+ 'AP Transaction Voucher Screen' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
+ 'Payment Transaction Voucher Screen' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
+ 'Payment Reversal Transaction Voucher Screen' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
+ 'GL Transaction Voucher Screen' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
+};
opendir (D62, 't/data/62.d');
for my $testfile (readdir(D62)){