Bug 12243: add regression test
authorGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 15:37:34 +0000 (15:37 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 19 May 2014 15:42:56 +0000 (15:42 +0000)
This patch adds a regression test for C4::Koha::NormalizeISBN
throwing an exception when trying to parse an invalid ISBN.

To test:

[1] Run prove -v t/Koha.t.  The last test should fail.
[2] Apply the main patch for this bug.
[3] Run prove -v t/Koha.t again.  This time, the test
    should pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/Koha.t

index 0cdbbb3..1f1e4db 100755 (executable)
--- a/t/Koha.t
+++ b/t/Koha.t
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 
 use C4::Context;
-use Test::More tests => 14;
+use Test::More tests => 15;
 use Test::MockModule;
 use DBD::Mock;
 
@@ -67,3 +67,9 @@ my @isbns = qw/ 978-0-321-49694-2 0-321-49694-9 978-0-321-49694-2 0321496949 978
 is( join('|', @isbns), join('|', GetVariationsOfISBN('978-0-321-49694-2 (pbk.)')), 'GetVariationsOfISBN returns all variations' );
 
 is( join('|', @isbns), join('|', GetVariationsOfISBNs('978-0-321-49694-2 (pbk.)')), 'GetVariationsOfISBNs returns all variations' );
+
+my $isbn;
+eval {
+    $isbn = C4::Koha::NormalizeISBN({ isbn => '0788893777 (2 DVD 45th ed)', format => 'ISBN-10', strip_hyphens => 1 });
+};
+ok($@ eq '', 'NormalizeISBN does not throw exception when parsing invalid ISBN (bug 12243)');