Bug 23219: (QA Follow up) Cancel patrons holds when patron delete
authorEmmi <emmi.takkinen@outlook.com>
Tue, 9 Jul 2019 06:24:30 +0000 (09:24 +0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 15 Jul 2019 11:48:49 +0000 (12:48 +0100)
Adds test for patrons holds cancelation when patron is deleted.

Test plan:
Run t/db_dependent/Koha/Patrons.t

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Koha/Patrons.t

index 9d5de6b..b98037a 100644 (file)
@@ -32,6 +32,7 @@ use C4::Biblio;
 use C4::Auth qw(checkpw_hash);
 
 use Koha::Holds;
+use Koha::Old::Holds;
 use Koha::Patrons;
 use Koha::Patron::Categories;
 use Koha::Database;
@@ -369,7 +370,7 @@ subtest "move_to_deleted" => sub {
 };
 
 subtest "delete" => sub {
-    plan tests => 5;
+    plan tests => 6;
     t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
     my $patron           = $builder->build( { source => 'Borrower' } );
     my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
@@ -389,6 +390,8 @@ subtest "delete" => sub {
 
     is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' );
 
+    is (Koha::Old::Holds->search( { reserve_id => $hold->{ reserve_id } } )->count, 1, q|Koha::Patron->delete should have cancelled patron's holds| );
+
     is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| );
 
     is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| );