+ $retrieved_patron->delete( $patron->{borrowernumber} ); # Cleanup
+};
+
+subtest "delete" => sub {
+ plan tests => 4;
+ t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
+ my $patron = $builder->build( { source => 'Borrower' } );
+ my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
+ my $hold = $builder->build(
+ { source => 'Reserve',
+ value => { borrowernumber => $patron->{borrowernumber} }
+ }
+ );
+ my $deleted = $retrieved_patron->delete;
+ is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' );
+ is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron');
+
+ is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| );
+
+ my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count;
+ is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' );