Bug 10519: (followup) unit tests leave problematic cruft
authorTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 14 Jul 2014 19:29:38 +0000 (16:29 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 23 Jan 2015 12:56:55 +0000 (13:56 +0100)
On testing I've found that t/db_dependent/Suggestions.t leaves
cruft on the DB. Small followup for that.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 724a68540c4fdf634becae7e26094d03dfcf963b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Conflicts:
t/db_dependent/Suggestions.t

t/db_dependent/Suggestions.t

index f285929..36a5d16 100644 (file)
@@ -1,28 +1,52 @@
 #!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# This Koha test module is a stub!
-# Add more tests here!!!
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
-use Data::Dumper;
+use Modern::Perl;
 
 use C4::Suggestions;
 
-use Test::More tests =>9;
+use Test::More tests => 10;
+use Test::Warn;
 
 BEGIN {
     use_ok('C4::Suggestions');
 }
 
+my $dbh = C4::Context->dbh;
+
+# Start transaction
+$dbh->{AutoCommit} = 0;
+$dbh->{RaiseError} = 1;
+
 my ($suggestionid, $suggestion, $status, $biblionumber);
 $biblionumber = 1;
 ok($suggestionid= NewSuggestion( {title=>'Petit traité de philosohpie',author=>'Hubert de Chardassé',publishercode=>'Albin Michel'} ), "NewSuggestion OK");
 ok($suggestion= GetSuggestion( $suggestionid), "GetSuggestion OK");
 ok($status= ModSuggestion( {title=>'test Modif Simple', suggestionid=>$suggestionid} ), "ModSuggestion Simple OK");
-ok($status= ModSuggestion( {STATUS=>'STALLED', suggestionid=>$suggestionid} ), "ModSuggestion Status OK");
+warning_is { $status = ModSuggestion( {STATUS=>'STALLED', suggestionid=>$suggestionid} )}
+           "No suggestions STALLED letter",
+           "ModSuggestion status warning is correct";
+ok( $status, "ModSuggestion Status OK");
 ok($status= ModSuggestion( {suggestionid => $suggestionid, biblionumber => $biblionumber } ), "ModSuggestion, set biblionumber OK" );
 ok($suggestion= GetSuggestionFromBiblionumber( $biblionumber ), "GetSuggestionFromBiblionumber OK");
 ok($suggestion= GetSuggestionInfoFromBiblionumber( $biblionumber ), "GetSuggestionInfoFromBiblionumber OK");
 ok(@{SearchSuggestion( {STATUS=>'STALLED'} )}>0, "SearchSuggestion Status OK");
 
+
+$dbh->rollback;
+
+1;