|
Lines 26-31
use Koha::Holds;
Link Here
|
| 26 |
use Koha::Patron; |
26 |
use Koha::Patron; |
| 27 |
use Koha::Patrons; |
27 |
use Koha::Patrons; |
| 28 |
use Koha::Database; |
28 |
use Koha::Database; |
|
|
29 |
use Koha::Virtualshelves; |
| 29 |
|
30 |
|
| 30 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 31 |
use t::lib::Mocks; |
32 |
use t::lib::Mocks; |
|
Lines 142-148
subtest "move_to_deleted" => sub {
Link Here
|
| 142 |
}; |
143 |
}; |
| 143 |
|
144 |
|
| 144 |
subtest "delete" => sub { |
145 |
subtest "delete" => sub { |
| 145 |
plan tests => 4; |
146 |
plan tests => 5; |
| 146 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
147 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
| 147 |
my $patron = $builder->build( { source => 'Borrower' } ); |
148 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 148 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
149 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
|
Lines 151-162
subtest "delete" => sub {
Link Here
|
| 151 |
value => { borrowernumber => $patron->{borrowernumber} } |
152 |
value => { borrowernumber => $patron->{borrowernumber} } |
| 152 |
} |
153 |
} |
| 153 |
); |
154 |
); |
|
|
155 |
my $list = $builder->build( |
| 156 |
{ source => 'Virtualshelve', |
| 157 |
value => { owner => $patron->{borrowernumber} } |
| 158 |
} |
| 159 |
); |
| 160 |
|
| 154 |
my $deleted = $retrieved_patron->delete; |
161 |
my $deleted = $retrieved_patron->delete; |
| 155 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
162 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
| 156 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron'); |
163 |
|
|
|
164 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' ); |
| 157 |
|
165 |
|
| 158 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
166 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
| 159 |
|
167 |
|
|
|
168 |
is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| ); |
| 169 |
|
| 160 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
170 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
| 161 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
171 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
| 162 |
}; |
172 |
}; |