Bug 21681: Add tests for GetPatronInfo
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 26 Oct 2018 18:25:09 +0000 (15:25 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 31 Oct 2018 13:52:08 +0000 (13:52 +0000)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
t/db_dependent/ILSDI_Services.t

index 9b6908f..f385627 100644 (file)
@@ -103,7 +103,7 @@ subtest 'AuthenticatePatron test' => sub {
 
 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
 
-    plan tests => 2;
+    plan tests => 4;
 
     $schema->storage->txn_begin;
 
@@ -191,7 +191,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
         }
     } );
 
-    $builder->build(
+    my $fine = $builder->build(
         {
             source => 'Accountline',
             value  => {
@@ -208,6 +208,7 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
     $query->param( 'service', 'GetPatronInfo' );
     $query->param( 'patron_id', $brwr->{'borrowernumber'} );
     $query->param( 'show_attributes', '1' );
+    $query->param( 'show_fines', '1' );
 
     my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
 
@@ -225,6 +226,13 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
     is( $reply->{'charges'}, '10.00',
         'The \'charges\' attribute should be correctly filled (bug 17836)' );
 
+    is( scalar( @{$reply->{fines}->{fine}}), 1, 'There should be only 1 account line');
+    is(
+        $reply->{fines}->{fine}->[0]->{accountlines_id},
+        $fine->{accountlines_id},
+        "The accountline should be the correct one"
+    );
+
     # Check results:
     is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' );