[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[2967] trunk/t
- Subject: SF.net SVN: ledger-smb:[2967] trunk/t
- From: ..hidden..
- Date: Mon, 15 Mar 2010 19:26:12 +0000
Revision: 2967
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2967&view=rev
Author: einhverfr
Date: 2010-03-15 19:26:12 +0000 (Mon, 15 Mar 2010)
Log Message:
-----------
Refactoring API tests to be more self-contained
Modified Paths:
--------------
trunk/t/01-load.t
trunk/t/62-api.t
trunk/t/data/62-request-data
Modified: trunk/t/01-load.t
===================================================================
--- trunk/t/01-load.t 2010-03-15 18:27:26 UTC (rev 2966)
+++ trunk/t/01-load.t 2010-03-15 19:26:12 UTC (rev 2967)
@@ -34,12 +34,12 @@
use_ok('LedgerSMB::Template::Elements');
use_ok('LedgerSMB::Template::CSV');
use_ok('LedgerSMB::Template::HTML');
-use_ok('LedgerSMB::Template::LaTeX');
SKIP: {
eval{ require Template::Plugin::Latex};
skip 'Template::Plugin::Latex not installed', 1 if @_;
- use_ok('LedgerSMB::Template::TXT');
+ use_ok('LedgerSMB::Template::LaTeX');
}
+use_ok('LedgerSMB::Template::TXT');
use_ok('LedgerSMB::User');
SKIP: {
Modified: trunk/t/62-api.t
===================================================================
--- trunk/t/62-api.t 2010-03-15 18:27:26 UTC (rev 2966)
+++ trunk/t/62-api.t 2010-03-15 19:26:12 UTC (rev 2967)
@@ -35,8 +35,8 @@
my $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} );
for my $test (@$test_request_data){
- if (ref $pre_test_subs->{"$test->{_test_id}"} eq 'CODE'){
- $pre_test_subs->{"$test->{_test_id}"}();
+ if (ref $test->{'_pre_test_sub'} eq 'CODE'){
+ $test->{'_pre_test_sub'}();
}
if (lc $test->{_codebase} eq 'old'){
next; # skip old codebase tests for now
@@ -63,20 +63,17 @@
$request->{action} = '__default';
}
$request->{dbh} = $dbh;
- if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
- $request->{_test_cases} =
- $api_test_cases->{"$test->{_test_id}"};
+ if (ref $test->{_api_test} eq 'CODE'){
+ $request->{_test_cases} = $test->{_api_test};
}
- 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");
}
- if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
- $request->{_test_cases} =
- $api_test_cases->{"$test->{_test_id}"};
+ if (ref $test->{_api_test} eq 'CODE'){
+ $request->{_test_cases} = $test->{_api_test};
}
ok($dbh->rollback, "$test->{_test_id}: rollback");
}
Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data 2010-03-15 18:27:26 UTC (rev 2966)
+++ trunk/t/data/62-request-data 2010-03-15 19:26:12 UTC (rev 2967)
@@ -12,6 +12,10 @@
'_codebase' => 'old',
'module' => 'ar.pl',
'action' => 'add'
+ '_api_test' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
},
{
'_test_id' => 'AP Transaction Screen',
@@ -97,6 +101,10 @@
'action' => 'create_batch',
'batch_type' => 'payable',
'module' => 'vouchers.pl',
+ '_api_test' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ };
},
{
'_test_id' => 'Payment Transaction Voucher Screen',
@@ -104,6 +112,10 @@
'action' => 'create_batch',
'batch_type' => 'payment',
'module' => 'vouchers.pl',
+ '_api_test' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
},
{
'_test_id' => 'Payment Reversal Transaction Voucher Screen',
@@ -111,6 +123,10 @@
'action' => 'create_batch',
'batch_type' => 'payment_reversal',
'module' => 'vouchers.pl',
+ '_api_test' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
},
{
'_test_id' => 'Income Statement Search Screen',
@@ -132,6 +148,10 @@
'action' => 'create_batch',
'batch_type' => 'gl',
'module' => 'vouchers.pl',
+ '_api_test' => sub {
+ my $request = shift;
+ ok($request->{batch_number}, 'Batch Number is Defined');
+ },
},
{
'_test_id' => 'Payment source start error',
@@ -143,6 +163,11 @@
'approved' => 0,
'currency' => 'USD',
'datepaid' => '2008-07-22',
+ '_api_test' => sub {
+ my $self = shift;
+ cmp_ok($self->{_error}, 'eq', 'No source start defined!',
+ "Payment source start error: error correct");
+ };
},
{
'_test_id' => 'Payment source numbering',
@@ -195,6 +220,18 @@
}
},
'_user' => { numberformat => '1,000.00', dateformat => 'yyyy-mm-dd' },
+ '_api_test' => sub {
+ my $self = shift;
+ $self->debug({file => '/tmp/test'});
+ ok(defined $self->{source_1},
+ "$self->{_test_id} source 1 defined");
+ cmp_ok($self->{source_2}, 'eq', '',
+ "$self->{_test_id} source 2 not found");
+ ok(defined $self->{source_3},
+ "$self->{_test_id} source 3 defined");
+ cmp_ok($self->{grand_total}, 'eq', '2,000.00',
+ "Grand total formatting works");
+ },
},
{
'_test_id' => 'Empty Recon Submission',
@@ -257,7 +294,7 @@
'contact_1' => '25',
'id_25' => '25',
'paid_25' => 'all',
- 'payment_209' => '1000.00',
+ 'payment_209' => '1000.00',
'invoice_25_1' => 209,
'net_209' => '1000.00',
'payment_210' => '-100.00',
@@ -289,70 +326,37 @@
'account_class' => 1,
'currency' => 'USD',
'multiple' => 1,
+ '_pre_test_sub' => sub {
+ $LedgerSMB::Sysconfig::check_max_invoices = 1;
+ },
+ '_api_test' => sub { use strict;
+ my $request = shift;
+ cmp_ok($request->{invoice_count_25},
+ '>',
+ $LedgerSMB::Sysconfig::check_max_invoices,
+ 'Test is valid under current config');
+ cmp_ok(scalar @{$request->{checks}},
+ '==',
+ $request->{contact_count},
+ 'Correct number of checks printed');
+ my $check = shift @{$request->{checks}};
+ cmp_ok(
+ $request->format_amount({
+ amount => $check->{amount},
+ format => '1000.00',
+ precision => 2
+ }),
+ 'eq',
+ '105900.00',
+ 'Printed amount is correct'
+ );
+ },
},
];
-our $pre_test_subs = {
- 'Payment print total' => sub {
- $LedgerSMB::Sysconfig::check_max_invoices = 1;
- },
-};
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');
- },
- 'Payment print total' => sub {
- use strict;
- my $request = shift;
- $request->debug({file => '/tmp/check' });
- cmp_ok($request->{invoice_count_25}, '>', $LedgerSMB::Sysconfig::check_max_invoices, 'Test is valid under current config');
- cmp_ok(scalar @{$request->{checks}}, '==',
- $request->{contact_count},
- 'Correct number of checks printed');
- my $check = shift @{$request->{checks}};
- cmp_ok(
- $request->format_amount({
- amount => $check->{amount},
- format => '1000.00',
- precision => 2
- }), 'eq', '105900.00',
- 'Printed amount is correct'
- );
- },
- 'Payment source start error' => sub {
- my $self = shift;
- cmp_ok($self->{_error}, 'eq', 'No source start defined!',
- "Payment source start error: error correct");
- },
- 'Payment source numbering' => sub {
- my $self = shift;
- $self->debug({file => '/tmp/test'});
- ok(defined $self->{source_1},
- "$self->{_test_id} source 1 defined");
- cmp_ok($self->{source_2}, 'eq', '',
- "$self->{_test_id} source 2 not found");
- ok(defined $self->{source_3},
- "$self->{_test_id} source 3 defined");
- cmp_ok($self->{grand_total}, 'eq', '2,000.00',
- "Grand total formatting works");
- }
};
opendir (D62, 't/data/62.d');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.