Lines 20-26
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use utf8; |
21 |
use utf8; |
22 |
|
22 |
|
23 |
use Test::More tests => 13; |
23 |
use Test::More tests => 14; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
|
25 |
|
26 |
use C4::Biblio qw( GetMarcSubfieldStructure ); |
26 |
use C4::Biblio qw( GetMarcSubfieldStructure ); |
Lines 1160-1162
subtest 'columns_to_str' => sub {
Link Here
|
1160 |
$schema->storage->txn_rollback; |
1160 |
$schema->storage->txn_rollback; |
1161 |
|
1161 |
|
1162 |
}; |
1162 |
}; |
1163 |
- |
1163 |
|
|
|
1164 |
subtest 'store() tests' => sub { |
1165 |
|
1166 |
plan tests => 1; |
1167 |
|
1168 |
subtest '_set_found_trigger() tests' => sub { |
1169 |
|
1170 |
plan tests => 6; |
1171 |
|
1172 |
$schema->storage->txn_begin; |
1173 |
|
1174 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
1175 |
my $item = $builder->build_sample_item({ itemlost => 1, itemlost_on => dt_from_string() }); |
1176 |
|
1177 |
# Add a lost item debit |
1178 |
my $debit = $patron->account->add_debit( |
1179 |
{ |
1180 |
amount => 10, |
1181 |
type => 'LOST', |
1182 |
item_id => $item->id, |
1183 |
interface => 'intranet', |
1184 |
} |
1185 |
); |
1186 |
|
1187 |
my $lostreturn_policy = 'charge'; |
1188 |
|
1189 |
my $mocked_circ_rules = Test::MockModule->new('Koha::CirculationRules'); |
1190 |
$mocked_circ_rules->mock( 'get_lostreturn_policy', sub { return $lostreturn_policy; } ); |
1191 |
|
1192 |
# simulate it was found |
1193 |
$item->set( { itemlost => 0 } )->store; |
1194 |
|
1195 |
my $messages = $item->messages; |
1196 |
|
1197 |
my $message_1 = $messages->[0]; |
1198 |
|
1199 |
is( $message_1->type, 'info', 'type is correct' ); |
1200 |
is( $message_1->message, 'lost_refunded', 'message is correct' ); |
1201 |
|
1202 |
# Find the refund credit |
1203 |
my $credit = $debit->credits->next; |
1204 |
|
1205 |
is_deeply( |
1206 |
$message_1->payload, |
1207 |
{ credit_id => $credit->id }, |
1208 |
'type is correct' |
1209 |
); |
1210 |
|
1211 |
my $message_2 = $messages->[1]; |
1212 |
|
1213 |
is( $message_2->type, 'info', 'type is correct' ); |
1214 |
is( $message_2->message, 'lost_charge', 'message is correct' ); |
1215 |
is( $message_2->payload, undef, 'no payload' ); |
1216 |
|
1217 |
$schema->storage->txn_rollback; |
1218 |
}; |
1219 |
}; |