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

SF.net SVN: ledger-smb:[2401] trunk



Revision: 2401
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2401&view=rev
Author:   einhverfr
Date:     2008-11-15 23:57:07 +0000 (Sat, 15 Nov 2008)

Log Message:
-----------
Test case additions, and a few corrections

Modified Paths:
--------------
    trunk/sql/modules/test/Voucher.sql
    trunk/t/42-dbobject.t

Added Paths:
-----------
    trunk/t/43-dbtest.t

Modified: trunk/sql/modules/test/Voucher.sql
===================================================================
--- trunk/sql/modules/test/Voucher.sql	2008-11-15 00:49:16 UTC (rev 2400)
+++ trunk/sql/modules/test/Voucher.sql	2008-11-15 23:57:07 UTC (rev 2401)
@@ -6,30 +6,30 @@
 	batch_create('_TEST', '_TEST', 'payment', '2008-01-01') IS NOT NULL;
 
 INSERT INTO entity (id, name, entity_class, control_code) 
-values (-2, 'Test', 1, 'test');
+values (-3, 'Test', 1, 'test');
 INSERT INTO entity_credit_account (entity_id, id, meta_number, entity_class) 
-values (-2, -1, 'Test', 1);
+values (-3, -1, 'Test', 1);
 
 INSERT INTO chart (id, accno, description, link)
-VALUES ('-1', '-21111', 'Testing AP', 'AP');
+VALUES ('-5', '-21111', 'Testing AP', 'AP');
 
 INSERT INTO ap (id, invnumber, amount, curr, approved, entity_credit_account)
-VALUES (-1, 'test1', '1000', 'USD', false, -1);
+VALUES (-5, 'test1', '1000', 'USD', false, -1);
 
 INSERT INTO acc_trans(trans_id, chart_id, amount, approved)
-values (-1, -1, 1000, true);
+values (-5, -5, 1000, true);
 
 INSERT INTO voucher (trans_id, batch_id, batch_class)
-values (-1, currval('batch_id_seq'), 1);
+values (-5, currval('batch_id_seq'), 1);
 INSERT INTO voucher (trans_id, batch_id, batch_class)
-values (-1, currval('batch_id_seq'), 3);
+values (-5, currval('batch_id_seq'), 3);
 INSERT INTO voucher (trans_id, batch_id, batch_class)
-values (-1, currval('batch_id_seq'), 3);
+values (-5, currval('batch_id_seq'), 3);
 
 
 INSERT INTO test_result (test_name, success)
 SELECT 'partial payment support', count(*) > 1 
-FROM voucher where trans_id = -1 and batch_class = 3;
+FROM voucher where trans_id = -5 and batch_class = 3;
 
 SELECT * FROM test_result;
 

Modified: trunk/t/42-dbobject.t
===================================================================
--- trunk/t/42-dbobject.t	2008-11-15 00:49:16 UTC (rev 2400)
+++ trunk/t/42-dbobject.t	2008-11-15 23:57:07 UTC (rev 2401)
@@ -1,5 +1,5 @@
 use LedgerSMB::DBObject;
-use Test::More tests => 5;
+use Test::More tests => 20;
 
 # Array parsing tests
 my $test = '{test,"test2\"\",",test3,"test4"}';
@@ -9,7 +9,16 @@
   is($_, shift @vals, "pass $pass, array parse test");
 }
 
-my $test2 = '{{1,1,1,1},{1,2,2,2}}';
-
+my $test2 = '{{1,1,1,1},{1,2,2,2},{1,3,3,4}}';
+my @test_arry2_c = ( [1,1,1,1], [1,2,2,2], [1,3,3,4]);
 my @test_arry2 = LedgerSMB::DBObject->_parse_array($test2);
-is(scalar @test_arry2, 2, 'Compount array with proper element count');
+is(scalar @test_arry2, 3, 'Compount array with proper element count');
+is(scalar @{$test_arry2[0]}, 4, 'Subarray 1 has correct element count');
+is(scalar @{$test_arry2[1]}, 4, 'Subarray 2 has correct element count');
+is(scalar @{$test_arry2[2]}, 4, 'Subarray 3 has correct element count');
+for my $outer(0 .. 2){
+    for my $inner(0 .. 3) {
+         is ($test_arry2[$outer]->[$inner], $test_arry2_c[$outer]->[$inner], 
+		"Compound array $outer/$inner correct");
+    }
+}

Added: trunk/t/43-dbtest.t
===================================================================
--- trunk/t/43-dbtest.t	                        (rev 0)
+++ trunk/t/43-dbtest.t	2008-11-15 23:57:07 UTC (rev 2401)
@@ -0,0 +1,24 @@
+use Test::More;
+use strict;
+
+if (!defined $ENV{PGDATABASE}){
+	plan skip_all => 'PGDATABASE Environment Variable not set up';
+}
+else {
+	plan tests => 50;
+}
+
+my @testscripts = qw(Account Business_type Company Draft Payment 
+			Session Voucher);
+
+chdir 'sql/modules/test/';
+
+for my $testscript (@testscripts){
+	open (TEST, '-|', "psql -f $testscript.sql");
+	my @testlines = grep /\|\s+(t|f)\s?$/, <TEST>;
+	cmp_ok(scalar @testlines, '>', 0, "$testscript.sql returned test results");
+	for my $test (@testlines){
+		my @parts = split /\|/, $test;
+		like($parts[1], qr/t/, $parts[0]);
+	}
+}


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