|
Lines 23-33
use C4::Biblio qw( AddBiblio );
Link Here
|
| 23 |
use Koha::Database; |
23 |
use Koha::Database; |
| 24 |
use Koha::Libraries; |
24 |
use Koha::Libraries; |
| 25 |
use Koha::Patrons; |
25 |
use Koha::Patrons; |
|
|
26 |
use Koha::Holds; |
| 26 |
use Koha::Item; |
27 |
use Koha::Item; |
| 27 |
use Koha::DateUtils; |
28 |
use Koha::DateUtils; |
| 28 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
| 29 |
|
30 |
|
| 30 |
use Test::More tests => 32; |
31 |
use Test::More tests => 33; |
| 31 |
use Test::Warn; |
32 |
use Test::Warn; |
| 32 |
|
33 |
|
| 33 |
use_ok('Koha::Hold'); |
34 |
use_ok('Koha::Hold'); |
|
Lines 144-147
ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same
Link Here
|
| 144 |
|
145 |
|
| 145 |
$schema->storage->txn_rollback(); |
146 |
$schema->storage->txn_rollback(); |
| 146 |
|
147 |
|
|
|
148 |
subtest "delete() tests" => sub { |
| 149 |
|
| 150 |
plan tests => 6; |
| 151 |
|
| 152 |
$schema->storage->txn_begin(); |
| 153 |
|
| 154 |
# Disable logging |
| 155 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
| 156 |
|
| 157 |
my $hold = $builder->build({ source => 'Reserve' }); |
| 158 |
|
| 159 |
my $hold_object = Koha::Holds->find( $hold->{ reserve_id } ); |
| 160 |
my $deleted = $hold_object->delete; |
| 161 |
is( $deleted, 1, 'Koha::Hold->delete should return 1 if the hold has been correctly deleted' ); |
| 162 |
is( Koha::Holds->search({ reserve_id => $hold->{ reserve_id } })->count, 0, |
| 163 |
"Koha::Hold->delete should have deleted the hold" ); |
| 164 |
|
| 165 |
my $number_of_logs = $schema->resultset('ActionLog')->search( |
| 166 |
{ module => 'HOLDS', action => 'DELETE', object => $hold->{ reserve_id } } )->count; |
| 167 |
is( $number_of_logs, 0, 'With HoldsLogs, Koha::Hold->delete shouldn\'t have been logged' ); |
| 168 |
|
| 169 |
# Enable logging |
| 170 |
t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); |
| 171 |
|
| 172 |
$hold = $builder->build({ source => 'Reserve' }); |
| 173 |
|
| 174 |
$hold_object = Koha::Holds->find( $hold->{ reserve_id } ); |
| 175 |
$deleted = $hold_object->delete; |
| 176 |
is( $deleted, 1, 'Koha::Hold->delete should return 1 if the hold has been correctly deleted' ); |
| 177 |
is( Koha::Holds->search({ reserve_id => $hold->{ reserve_id } })->count, 0, |
| 178 |
"Koha::Hold->delete should have deleted the hold" ); |
| 179 |
|
| 180 |
$number_of_logs = $schema->resultset('ActionLog')->search( |
| 181 |
{ module => 'HOLDS', action => 'DELETE', object => $hold->{ reserve_id } } )->count; |
| 182 |
is( $number_of_logs, 1, 'With HoldsLogs, Koha::Hold->delete should have been logged' ); |
| 183 |
|
| 184 |
$schema->storage->txn_rollback(); |
| 185 |
}; |
| 186 |
|
| 147 |
1; |
187 |
1; |
| 148 |
- |
|
|