Bug 7288: (follow-up) add unit test for is_linked_to_subscriptions flag
authorGalen Charlton <gmc@esilibrary.com>
Mon, 21 Apr 2014 05:16:29 +0000 (05:16 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 21 Apr 2014 05:16:29 +0000 (05:16 +0000)
This adds a direct unit test of the is_linked_to_subscriptions flag
and corrects a typo in the previously-submitted test.

To test:

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

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

index b7d75b2..4123c1e 100644 (file)
@@ -180,7 +180,7 @@ is(scalar @invoices, $invoicecount - 1, 'DelInvoice deletes invoice');
 is(GetInvoice($invoiceid3), undef, 'DelInvoice deleted correct invoice');
 
 my @invoices_linked_to_subscriptions = map{
-    $_->{linked_to_subscriptions}
+    $_->{is_linked_to_subscriptions}
     ? $_
     : ()
 } @invoices;
index 12ca9a4..5133d52 100644 (file)
@@ -1,6 +1,6 @@
 use Modern::Perl;
 
-use Test::More tests => 12;
+use Test::More tests => 13;
 use Data::Dumper;
 
 use_ok('C4::Acquisition');
@@ -82,6 +82,9 @@ my $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscript
 is ( $order->{subscriptionid}, $subscription->{subscriptionid}, "test subscriptionid for the last order not received");
 ok( $order->{ecost} == $cost, "test cost for the last order not received");
 
+$dbh->do(q{DELETE FROM aqinvoices});
+my $invoiceid = AddInvoice(invoicenumber => 'invoice1', booksellerid => $booksellerid, unknown => "unknown");
+
 my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
     {
         biblionumber     => $biblionumber,
@@ -91,7 +94,8 @@ my ( $datereceived, $new_ordernumber ) = ModReceiveOrder(
         ecost            => $cost,
         rrp              => $cost,
         budget_id        => $budget_id,
-        datereceived     => '02-01-2013'
+        datereceived     => '02-01-2013',
+        invoiceid        => $invoiceid,
     }
 );
 
@@ -102,5 +106,9 @@ ok( $order->{ecost} == $cost, "test cost for the last order received");
 $order = GetLastOrderNotReceivedFromSubscriptionid( $subscription->{subscriptionid} );
 is ( $order, undef, "test no not received order for a received order");
 
+my @invoices = GetInvoices();
+my @invoices_linked_to_subscriptions = grep { $_->{is_linked_to_subscriptions} } @invoices;
+is(scalar(@invoices_linked_to_subscriptions), 1, 'GetInvoices() can identify invoices that are linked to a subscription');
+
 # Cleanup
 $dbh->rollback;