Lines 25-30
use Koha::Holds;
Link Here
|
25 |
use Koha::Patron; |
25 |
use Koha::Patron; |
26 |
use Koha::Patrons; |
26 |
use Koha::Patrons; |
27 |
use Koha::Database; |
27 |
use Koha::Database; |
|
|
28 |
use Koha::Virtualshelves; |
28 |
|
29 |
|
29 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
30 |
use t::lib::Mocks; |
31 |
use t::lib::Mocks; |
Lines 114-120
subtest "move_to_deleted" => sub {
Link Here
|
114 |
}; |
115 |
}; |
115 |
|
116 |
|
116 |
subtest "delete" => sub { |
117 |
subtest "delete" => sub { |
117 |
plan tests => 4; |
118 |
plan tests => 5; |
118 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
119 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
119 |
my $patron = $builder->build( { source => 'Borrower' } ); |
120 |
my $patron = $builder->build( { source => 'Borrower' } ); |
120 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
121 |
my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
Lines 123-134
subtest "delete" => sub {
Link Here
|
123 |
value => { borrowernumber => $patron->{borrowernumber} } |
124 |
value => { borrowernumber => $patron->{borrowernumber} } |
124 |
} |
125 |
} |
125 |
); |
126 |
); |
|
|
127 |
my $list = $builder->build( |
128 |
{ source => 'Virtualshelve', |
129 |
value => { owner => $patron->{borrowernumber} } |
130 |
} |
131 |
); |
132 |
|
126 |
my $deleted = $retrieved_patron->delete; |
133 |
my $deleted = $retrieved_patron->delete; |
127 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
134 |
is( $deleted, 1, 'Koha::Patron->delete should return 1 if the patron has been correctly deleted' ); |
128 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron'); |
135 |
|
|
|
136 |
is( Koha::Patrons->find( $patron->{borrowernumber} ), undef, 'Koha::Patron->delete should have deleted the patron' ); |
129 |
|
137 |
|
130 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
138 |
is( Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's holds| ); |
131 |
|
139 |
|
|
|
140 |
is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| ); |
141 |
|
132 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
142 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; |
133 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
143 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); |
134 |
}; |
144 |
}; |