Bug 21301: add unit tests
authorFridolin Somers <fridolin.somers@biblibre.com>
Fri, 4 Sep 2020 08:01:20 +0000 (10:01 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Jan 2021 10:17:33 +0000 (11:17 +0100)
Run t/db_dependent/ILSDI_Services.t with and without previous patches

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/ILSDI_Services.t

index 5e38a12..3ce217b 100755 (executable)
@@ -572,7 +572,7 @@ subtest 'Holds test with start_date and end_date' => sub {
 
 subtest 'GetRecords' => sub {
 
-    plan tests => 1;
+    plan tests => 8;
 
     $schema->storage->txn_begin;
 
@@ -591,6 +591,24 @@ subtest 'GetRecords' => sub {
         }
     );
 
+    my $patron = $builder->build({
+        source => 'Borrower',
+    });
+
+    my $issue = $builder->build({
+        source => 'Issue',
+        value => {
+            itemnumber => $item->itemnumber,
+        }
+    });
+
+    my $hold = $builder->build({
+        source => 'Reserve',
+        value => {
+            biblionumber => $item->biblionumber,
+        }
+    });
+
     ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode});
 
     my $cgi = CGI->new;
@@ -608,6 +626,17 @@ subtest 'GetRecords' => sub {
     is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
         'GetRecords returns transfer informations');
 
+    # Check informations exposed
+    my $reply_issue = $reply->{record}->[0]->{issues}->{issue}->[0];
+    is($reply_issue->{itemnumber}, $item->itemnumber, 'GetRecords has an issue tag');
+    is($reply_issue->{borrowernumber}, undef, 'GetRecords does not expose borrowernumber in issue tag');
+    is($reply_issue->{surname}, undef, 'GetRecords does not expose surname in issue tag');
+    is($reply_issue->{firstname}, undef, 'GetRecords does not expose firstname in issue tag');
+    is($reply_issue->{cardnumber}, undef, 'GetRecords does not expose cardnumber in issue tag');
+    my $reply_reserve = $reply->{record}->[0]->{reserves}->{reserve}->[0];
+    is($reply_reserve->{biblionumber}, $item->biblionumber, 'GetRecords has a reserve tag');
+    is($reply_reserve->{borrowernumber}, undef, 'GetRecords does not expose borrowernumber in reserve tag');
+
     $schema->storage->txn_rollback;
 };