Bug 21975: add Unit Test
authorFridolin Somers <fridolin.somers@biblibre.com>
Fri, 7 Dec 2018 14:21:48 +0000 (15:21 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 25 Apr 2019 14:17:57 +0000 (15:17 +0100)
Added missing transaction rollback

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 0be8fd212067ebd4b36e00b4d139761aa0e021c3)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Items/AutomaticItemModificationByAge.t

index 17172be..f27eb95 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 use Modern::Perl;
-use Test::More tests => 16;
+use Test::More tests => 17;
 use MARC::Record;
 use MARC::Field;
 use DateTime;
@@ -11,6 +11,7 @@ use C4::Items;
 use C4::Biblio;
 use C4::Context;
 use Koha::DateUtils;
+use t::lib::Mocks;
 use t::lib::TestBuilder;
 
 my $schema = Koha::Database->new->schema;
@@ -298,9 +299,16 @@ C4::Items::ToggleNewStatus( { rules => \@rules } );
 $modified_item = C4::Items::GetItem( $itemnumber );
 is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|);
 
-# Clear cache
+# Run twice
+t::lib::Mocks::mock_preference('CataloguingLog', 1);
+my $actions_nb = $schema->resultset('ActionLog')->count();
+C4::Items::ToggleNewStatus( { rules => \@rules } );
+is( $schema->resultset('ActionLog')->count(), $actions_nb, q|ToggleNewStatus: no substitution does not generate action logs|);
+
+# Cleanup
 $cache = Koha::Caches->get_instance();
 $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
 $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
 $cache->clear_from_cache("default_value_for_mod_marc-");
 $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
+$schema->storage->txn_rollback;