View | Details | Raw Unified | Return to bug 26704
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Item.t (-2 / +58 lines)
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 1167-1169 subtest 'columns_to_str' => sub { Link Here
1167
    $schema->storage->txn_rollback;
1167
    $schema->storage->txn_rollback;
1168
1168
1169
};
1169
};
1170
- 
1170
1171
subtest 'store() tests' => sub {
1172
1173
    plan tests => 1;
1174
1175
    subtest '_set_found_trigger() tests' => sub {
1176
1177
        plan tests => 6;
1178
1179
        $schema->storage->txn_begin;
1180
1181
        my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1182
        my $item   = $builder->build_sample_item({ itemlost => 1, itemlost_on => dt_from_string() });
1183
1184
        # Add a lost item debit
1185
        my $debit = $patron->account->add_debit(
1186
            {
1187
                amount    => 10,
1188
                type      => 'LOST',
1189
                item_id   => $item->id,
1190
                interface => 'intranet',
1191
            }
1192
        );
1193
1194
        my $lostreturn_policy = 'charge';
1195
1196
        my $mocked_circ_rules = Test::MockModule->new('Koha::CirculationRules');
1197
        $mocked_circ_rules->mock( 'get_lostreturn_policy', sub { return $lostreturn_policy; } );
1198
1199
        # simulate it was found
1200
        $item->set( { itemlost => 0 } )->store;
1201
1202
        my $messages = $item->messages;
1203
1204
        my $message_1 = $messages->[0];
1205
1206
        is( $message_1->type,    'info',          'type is correct' );
1207
        is( $message_1->message, 'lost_refunded', 'message is correct' );
1208
1209
        # Find the refund credit
1210
        my $credit = $debit->credits->next;
1211
1212
        is_deeply(
1213
            $message_1->payload,
1214
            { credit_id => $credit->id },
1215
            'type is correct'
1216
        );
1217
1218
        my $message_2 = $messages->[1];
1219
1220
        is( $message_2->type,    'info',        'type is correct' );
1221
        is( $message_2->message, 'lost_charge', 'message is correct' );
1222
        is( $message_2->payload, undef,         'no payload' );
1223
1224
        $schema->storage->txn_rollback;
1225
    };
1226
};

Return to bug 26704