From bda04bbe95f0ff8996619a5c2599b070d4a7326f Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sat, 22 Nov 2008 21:38:18 +0000 Subject: Batch numbers assigned at batch creation phase. Tests working. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2414 4979c152-3d1c-0410-bac9-87ea11338e46 --- t/62-api.t | 16 ++++++++++++---- t/data/62-request-data | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 't') 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)){ -- cgit v1.2.3