Bug 15690: CardnumberLength should not be bigger than 16
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Sep 2016 14:43:50 +0000 (15:43 +0100)
committerJulian Maurice <julian.maurice@biblibre.com>
Wed, 30 Nov 2016 12:25:00 +0000 (13:25 +0100)
borrowers.cardnumber is a varchar(16), so CardnumberLength should not
have a max > 16

Test plan:
Test different value in CardnumberLength ("20", "20,30", "40,")
Edit a patron a make sure the text display under the cardnumber input is
correct

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Marc <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 87380d8b460857157b4cf06fa8def626d1d2badb)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>

C4/Members.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
t/Members/cardnumber.t

index 32acf4a..47722d4 100644 (file)
@@ -1359,6 +1359,7 @@ sub get_cardnumber_length {
         }
 
     }
+    $min = 16 if $min > 16;
     return ( $min, $max );
 }
 
index fc489f2..254723d 100644 (file)
@@ -140,7 +140,7 @@ Patrons:
          - Card numbers for patrons must be
          - pref: CardnumberLength
          - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
-         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one."
+         - "If 'cardnumber' is included in the BorrowerMandatoryField list, the minimum length, if not specified here, defaults to one. Maximum cannot be bigger than 16."
      -
          - pref: useDischarge
            choices:
index b2ec79f..deb76de 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 
 use Modern::Perl;
-use Test::More tests => 23;
+use Test::More tests => 25;
 
 use t::lib::Mocks;
 
@@ -67,5 +67,13 @@ is( C4::Members::checkcardnumber( q{1234567890123456} ), 2, "1234567890123456 is
 $dbh->{mock_add_resultset} = $rs;
 is( C4::Members::checkcardnumber( q{1234567890} ), 2, "1234567890 is longer than $pref");
 
+$pref = q|,40|; # max 40 chars, not allowed
+t::lib::Mocks::mock_preference('CardnumberLength', $pref);
+is_deeply( [ C4::Members::get_cardnumber_length() ], [ 0, 16 ], ',40 => min=0 and max=16');
+$dbh->{mock_add_resultset} = $rs;
+is( C4::Members::checkcardnumber( q{12345678901234567890} ), 2, "12345678901234567890 is longer than $pref => 16 is max!");
+
+$pref = q|,8|; # max 8 chars
+t::lib::Mocks::mock_preference('CardnumberLength', $pref);
 t::lib::Mocks::mock_preference('BorrowerMandatoryField', 'cardnumber');
 is_deeply( [ C4::Members::get_cardnumber_length() ], [ 1, 8 ], ',8 => min=1 and max=8 if cardnumber is mandatory');