Bug 16609: Catch warning from Koha::Hold in Hold.t
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 27 May 2016 12:02:42 +0000 (14:02 +0200)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 10 Jun 2016 17:42:03 +0000 (17:42 +0000)
Before this patch, the suspend step triggers a warn from Koha::Hold.
Now we catch it.

Test plan:
Run the test. Do not see the warning about unable to suspend.

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

NOTE: Nice clean up!

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

t/db_dependent/Hold.t

index 204d60e..9604bd8 100755 (executable)
@@ -27,7 +27,8 @@ use Koha::Item;
 use Koha::DateUtils;
 use t::lib::TestBuilder;
 
-use Test::More tests => 31;
+use Test::More tests => 32;
+use Test::Warn;
 
 use_ok('Koha::Hold');
 
@@ -86,7 +87,8 @@ $hold->resume();
 is( $hold->suspend, 0, "Hold is not suspended" );
 is( $hold->suspend_until, undef, "Hold no longer has suspend_until date" );
 $hold->found('W');
-$hold->suspend_hold();
+warning_like { $hold->suspend_hold }
+    qr/Unable to suspend waiting hold!/, 'Catch warn about failed suspend';
 is( $hold->suspend, 0, "Waiting hold cannot be suspended" );
 
 $item = $hold->item();