Bug 19386: Prevent t/db_dependent/SIP/Patron.t to fail randomly
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 28 Sep 2017 20:31:04 +0000 (17:31 -0300)
committerKatrin Fischer <katrin.fischer.83@web.de>
Sun, 29 Oct 2017 18:47:58 +0000 (19:47 +0100)
Depending on the values used by TestBuilder, some tests from t/db_dependent/SIP/Patron.t can fail

    #   Failed test 'Not blocked without overdues when set to 'Don't block''
    #   at t/db_dependent/SIP/Patron.t line 55.
    #          got: '0'
    #     expected: '1'

    #   Failed test 'Not blocked without overdues when set to 'confirmation''
    #   at t/db_dependent/SIP/Patron.t line 61.
    #          got: '0'
    #     expected: '1'

    #   Failed test 'Not blocked without overdues when set to 'Block''
    #   at t/db_dependent/SIP/Patron.t line 67.
    #          got: '0'
    #     expected: '1'

Caused by this check in C4::SIP::ILS::Patron->new
110     for (qw(EXPIRED CHARGES CREDITS GNA LOST DBARRED NOTES)) {
111         ($flags->{$_}) or next;
[...]
115         if ($flags->{$_}->{noissues}) {
116             foreach my $toggle (qw(charge_ok renew_ok recall_ok hold_ok inet)) {
117                 $ilspatron{$toggle} = 0;    # if we get noissues, disable everything
118             }
119         }
120     }

Test plan:
Execute several times (50x?) these tests.
Without this patch they may fail
With this patch they must never fail

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 6545cfe3f30789723b6f3c2e6e13af6e6c8e5fb9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 40c444cc2bd664babd30ca4ed70c4953cfb916d5)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

t/db_dependent/SIP/Patron.t

index 28009df..cbcebb1 100755 (executable)
@@ -31,8 +31,28 @@ subtest "OverduesBlockCirc tests" => sub {
 
     plan tests => 6;
 
-    my $odue_patron = $builder->build({ source => 'Borrower' });
-    my $good_patron = $builder->build({ source => 'Borrower' });
+    my $odue_patron = $builder->build(
+        {
+            source => 'Borrower',
+            value  => {
+                debarred      => undef,
+                dateexpiry    => "3000-01-01",
+                lost          => 0,
+                gonenoaddress => 0,
+            }
+        }
+    );
+    my $good_patron = $builder->build(
+        {
+            source => 'Borrower',
+            value  => {
+                debarred      => undef,
+                dateexpiry    => "3000-01-01",
+                lost          => 0,
+                gonenoaddress => 0,
+            }
+        }
+    );
     my $odue = $builder->build({ source => 'Issue', value => {
             borrowernumber => $odue_patron->{borrowernumber},
             date_due => '2017-01-01',