Bug 10723: (follow-up) add more unit tests for SearchOrders()
authorGalen Charlton <gmc@esilibrary.com>
Mon, 21 Oct 2013 18:49:37 +0000 (18:49 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 21 Oct 2013 18:49:37 +0000 (18:49 +0000)
In particular, verify that the pending filter option works.

To test:

[1] Verify that prove -v t/db_dependent/Acquisition.t passes

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/db_dependent/Acquisition.t

index 90d5a88..202641f 100755 (executable)
@@ -8,7 +8,7 @@ use POSIX qw(strftime);
 
 use C4::Bookseller qw( GetBookSellerFromId );
 
-use Test::More tests => 41;
+use Test::More tests => 44;
 
 BEGIN {
     use_ok('C4::Acquisition');
@@ -85,6 +85,7 @@ my $orders = SearchOrders({
     pending => 1
 });
 isa_ok( $orders, 'ARRAY' );
+is(scalar(@$orders), 3, 'retrieved 3 pending orders');
 
 C4::Acquisition::CloseBasket( $basketno );
 my @lateorders = GetLateOrders(0);
@@ -129,4 +130,20 @@ for my $field ( @expectedfields ) {
     ok( exists( $firstorder->{ $field } ), "This order has a $field field" );
 }
 
+# fake receiving the order
+ModOrder({
+    ordernumber      => $firstorder->{ordernumber},
+    biblionumber     => $firstorder->{biblionumber},
+    quantityreceived => $firstorder->{quantity},
+});
+my $pendingorders = SearchOrders({
+    booksellerid => $booksellerid,
+    pending => 1
+});
+is(scalar(@$pendingorders), 2, 'retrieved 2 pending orders after receiving on one (bug 10723)');
+my $allorders = SearchOrders({
+    booksellerid => $booksellerid,
+});
+is(scalar(@$allorders), 3, 'retrieved all 3 orders even after after receiving on one (bug 10723)');
+
 $dbh->rollback;