Lines 223-229
subtest "move_to_deleted" => sub {
Link Here
|
223 |
}; |
223 |
}; |
224 |
|
224 |
|
225 |
subtest "delete" => sub { |
225 |
subtest "delete" => sub { |
226 |
plan tests => 4; |
226 |
plan tests => 5; |
227 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
227 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
228 |
my $patron = $builder->build( { source => 'Borrower' } ); |
228 |
my $patron = $builder->build( { source => 'Borrower' } ); |
229 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
229 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
Lines 232-243
subtest "delete" => sub {
Link Here
|
232 |
value => { borrowernumber => $patron->{borrowernumber} } |
232 |
value => { borrowernumber => $patron->{borrowernumber} } |
233 |
} |
233 |
} |
234 |
); |
234 |
); |
|
|
235 |
my $list = $builder->build( |
236 |
{ source => 'Virtualshelve', |
237 |
value => { owner => $patron->{borrowernumber} } |
238 |
} |
239 |
); |
240 |
|
235 |
my $deleted = $retrieved_patron->delete; |
241 |
my $deleted = $retrieved_patron->delete; |
236 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
242 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
237 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron'); |
243 |
|
|
|
244 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' ); |
238 |
|
245 |
|
239 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
246 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
240 |
|
247 |
|
|
|
248 |
is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| ); |
249 |
|
241 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
250 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
242 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
251 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
243 |
}; |
252 |
}; |