Bug 20499: Unit Test to prove the problem
authorMark Tompsett <mtompset@hotmail.com>
Thu, 29 Mar 2018 18:44:32 +0000 (18:44 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 13 Apr 2018 14:49:13 +0000 (11:49 -0300)
TEST PLAN
---------
1) apply this patch
2) prove t/db_dependent/Circulation.t
   -- horrible death.
3) apply next path
4) prove t/db_dependent/Circulation.t
   -- passes.
5) run koha qa test tools

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

t/db_dependent/Circulation.t

index 497df64..bc14b53 100755 (executable)
@@ -1193,7 +1193,7 @@ C4::Context->dbh->do("DELETE FROM accountlines");
 }
 
 subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
-    plan tests => 23;
+    plan tests => 24;
 
     my $homebranch    = $builder->build( { source => 'Branch' } );
     my $holdingbranch = $builder->build( { source => 'Branch' } );
@@ -1225,6 +1225,10 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
 
     # AllowReturnToBranch == anywhere
     t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
+    ## Test that unknown barcodes don't generate internal server errors
+    set_userenv($homebranch);
+    ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, 'KohaIsAwesome' );
+    ok( $error->{UNKNOWN_BARCODE}, '"KohaIsAwesome" is not a valid barcode as expected.' );
     ## Can be issued from homebranch
     set_userenv($homebranch);
     ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );