[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2418] trunk/t



Revision: 2418
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2418&view=rev
Author:   einhverfr
Date:     2008-11-23 00:07:20 +0000 (Sun, 23 Nov 2008)

Log Message:
-----------
Test case for print_max_invoices bug added

Modified Paths:
--------------
    trunk/t/62-api.t
    trunk/t/data/62-request-data

Modified: trunk/t/62-api.t
===================================================================
--- trunk/t/62-api.t	2008-11-22 23:10:53 UTC (rev 2417)
+++ trunk/t/62-api.t	2008-11-23 00:07:20 UTC (rev 2418)
@@ -2,6 +2,7 @@
 	use LedgerSMB;
 	use Test::More;
 	use LedgerSMB::Template;
+	use LedgerSMB::Sysconfig;
 	use LedgerSMB::DBTest;
 }
 
@@ -31,6 +32,7 @@
 } # Import new code namespaces
 
 my $dbh = LedgerSMB::DBTest->connect("dbi:Pg:dbname=$ENV{PGDATABASE}", undef, undef);
+my $locale = LedgerSMB::Locale->get_handle( ${LedgerSMB::Sysconfig::language} );
 
 for my $test (@$test_request_data){
 	if (lc $test->{_codebase} eq 'old'){
@@ -52,6 +54,7 @@
 	} else {
 		my $request = LedgerSMB->new();
 		$request->merge($test);
+		$request->{_locale} = $locale;
 		my $script = $test->{module};
 		$request->{dbh} = $dbh;
 		if (ref $api_test_cases->{"$test->{_test_id}"} eq 'CODE'){
@@ -83,6 +86,9 @@
 	return 1;
 }
 
+sub _http_output {
+	return 1;
+}
 package old_code_test;
 # Keeps old code isolated in a different namespace, and provides for reasonable 
 # reload facilities.

Modified: trunk/t/data/62-request-data
===================================================================
--- trunk/t/data/62-request-data	2008-11-22 23:10:53 UTC (rev 2417)
+++ trunk/t/data/62-request-data	2008-11-23 00:07:20 UTC (rev 2418)
@@ -49,17 +49,50 @@
 		'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'	=> 
-#                
-#	},
+	{
+		'_test_id'      => 'Payment print total',
+		'_codebase'     => 'new',
+		'action'        => 'print',
+		'approved'      => 0,		
+		'currency'      => 'USD',				
+		'datepaid'      => '2008-07-22',	
+		'contact_1'	=> '25',				
+		'id_25'         => '25',				
+		'paid_25'       => 'all',		
+                'payment_209'   => '1000.00',	
+		'invoice_25_1'  => 209,
+		'net_209'	=> '1000.00',				
+		'payment_210'	=> '-100.00',
+		'invoice_25_2'	=> '210',
+		'net_210'	=> '-100.00',
+		'payment_344'	=> '100000.00',
+		'invoice_25_3'	=> '344',
+		'net_344'	=> '100000.00',
+		'payment_352'	=> '1000.00',
+		'invoice_25_4'	=> '352',
+		'net_352'	=> '1000.00',
+		'payment_353'	=> '1000.00',
+		'invoice_25_5'	=> '353',
+		'net_353'	=> '1000.00',
+		'payment_354'	=> '1000.00',
+		'invoice_25_6'	=> '354',
+		'net_354'	=> '1000.00',
+		'payment_355'	=> '1000.00',
+		'invoice_25_7'	=> '355',
+		'net_355'	=> '1000.00',
+		'payment_356'	=> '1000.00',
+		'invoice_25_8'	=> '356',
+		'net_356'	=> '1000.00',
+		'invoice_count_25' => 8,				
+		'contact_count'	=> 1,				
+		'media'		=> 'screen',	
+		'format'	=> 'PDF',			
+		'module'        => 'payment.pl',
+		'account_class' => 1,
+		'currency'      => 'USD',
+		'multiple'      => 1,
+               
+	},
 ];
 
 our $pre_test_subs = {};
@@ -84,6 +117,23 @@
 		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(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'
+		);
+	}
 };
 
 opendir (D62, 't/data/62.d');


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.