Lines 1101-1110
subtest 'cancel() tests' => sub {
Link Here
|
1101 |
# Mock GetPreparedLetter so it raises a warning we can look for |
1101 |
# Mock GetPreparedLetter so it raises a warning we can look for |
1102 |
# and returns undef, so no call to EnqueueLetter happens |
1102 |
# and returns undef, so no call to EnqueueLetter happens |
1103 |
my $mocked_letter = Test::MockModule->new("C4::Letters"); |
1103 |
my $mocked_letter = Test::MockModule->new("C4::Letters"); |
1104 |
$mocked_letter->mock( 'GetPreparedLetter', sub { |
1104 |
$mocked_letter->mock( |
1105 |
$get_prepared_letter_called = 1; |
1105 |
'GetPreparedLetter', |
1106 |
return; |
1106 |
sub { |
1107 |
}); |
1107 |
$get_prepared_letter_called = 1; |
|
|
1108 |
return; |
1109 |
} |
1110 |
); |
1108 |
|
1111 |
|
1109 |
my $hold = $builder->build_object( |
1112 |
my $hold = $builder->build_object( |
1110 |
{ |
1113 |
{ |
Lines 1119-1125
subtest 'cancel() tests' => sub {
Link Here
|
1119 |
|
1122 |
|
1120 |
# leave this things out of the test |
1123 |
# leave this things out of the test |
1121 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 ); |
1124 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 ); |
1122 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
1125 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
1123 |
|
1126 |
|
1124 |
$hold = $builder->build_object( |
1127 |
$hold = $builder->build_object( |
1125 |
{ |
1128 |
{ |
Lines 1133-1143
subtest 'cancel() tests' => sub {
Link Here
|
1133 |
); |
1136 |
); |
1134 |
|
1137 |
|
1135 |
$get_prepared_letter_called = 0; |
1138 |
$get_prepared_letter_called = 0; |
1136 |
$hold->cancel({ cancellation_reason => 'Some reason' }); |
1139 |
$hold->cancel( { cancellation_reason => 'Some reason' } ); |
1137 |
ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' ); |
1140 |
ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' ); |
1138 |
|
1141 |
|
1139 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1142 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1140 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1143 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1141 |
is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); |
1144 |
is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); |
1142 |
|
1145 |
|
1143 |
$hold = $builder->build_object( |
1146 |
$hold = $builder->build_object( |
Lines 1152-1162
subtest 'cancel() tests' => sub {
Link Here
|
1152 |
); |
1155 |
); |
1153 |
|
1156 |
|
1154 |
$get_prepared_letter_called = 0; |
1157 |
$get_prepared_letter_called = 0; |
1155 |
$hold->cancel({ cancellation_reason => 'Some reason', notify_patron => 1 }); |
1158 |
$hold->cancel( { cancellation_reason => 'Some reason', notify_patron => 1 } ); |
1156 |
ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' ); |
1159 |
ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' ); |
1157 |
|
1160 |
|
1158 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1161 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1159 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1162 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1160 |
is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); |
1163 |
is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); |
1161 |
|
1164 |
|
1162 |
$hold = $builder->build_object( |
1165 |
$hold = $builder->build_object( |
Lines 1171-1179
subtest 'cancel() tests' => sub {
Link Here
|
1171 |
); |
1174 |
); |
1172 |
|
1175 |
|
1173 |
$get_prepared_letter_called = 0; |
1176 |
$get_prepared_letter_called = 0; |
1174 |
$hold->cancel({ notify_patron => 1 }); |
1177 |
$hold->cancel( { notify_patron => 1 } ); |
1175 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1178 |
isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); |
1176 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1179 |
is( $hold->priority, 0, 'priority gets set to 0' ); |
1177 |
is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' ); |
1180 |
is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' ); |
1178 |
|
1181 |
|
1179 |
$schema->storage->txn_rollback; |
1182 |
$schema->storage->txn_rollback; |
1180 |
- |
|
|