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

(-)a/t/db_dependent/Koha/Item.t (-2 / +60 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 => 29;
23
use Test::More tests => 30;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
26
Lines 1176-1181 subtest 'get_transfers' => sub { Link Here
1176
    $schema->storage->txn_rollback;
1176
    $schema->storage->txn_rollback;
1177
};
1177
};
1178
1178
1179
subtest 'Test for relationship between item and current_branchtransfers' => sub {
1180
    plan tests => 4;
1181
1182
    $schema->storage->txn_begin;
1183
1184
    my $item     = $builder->build_sample_item();
1185
    my $transfer = $builder->build_object(
1186
        {
1187
            class => 'Koha::Item::Transfers',
1188
            value => {
1189
                itemnumber => $item->itemnumber,
1190
                datesent => dt_from_string,
1191
                datearrived => dt_from_string,
1192
                datecancelled => undef,
1193
            }
1194
        }
1195
    );
1196
1197
    my $transfer_item = $transfer->item;
1198
    my $biblio = Koha::Biblios->find($transfer_item->biblionumber);
1199
1200
    my $current_branchtransfers = Koha::Items->search( {
1201
            'me.itemnumber' => $transfer_item->itemnumber
1202
        }, {
1203
            prefetch => ['current_branchtransfers']
1204
        }
1205
    );
1206
1207
    my $item_with_branchtransfers = $current_branchtransfers->next;
1208
1209
    is($transfer_item->itemnumber, $item_with_branchtransfers->itemnumber,
1210
       'following two items are the same');
1211
1212
    # following two tests should produce the same result
1213
    is($transfer_item->get_transfer, undef,
1214
       'Koha::Item->get_transfer returns undef with no active transfers');
1215
    is($item_with_branchtransfers->get_transfer, undef,
1216
       'prefetched result->get_transfer returns undef with no active transfers');
1217
1218
    $transfer->set({
1219
        datearrived => undef,
1220
    })->store;
1221
    
1222
    $current_branchtransfers = Koha::Items->search( {
1223
            'me.itemnumber' => $transfer_item->itemnumber
1224
        }, {
1225
            prefetch => ['current_branchtransfers']
1226
        }
1227
    );
1228
1229
    $item_with_branchtransfers = $current_branchtransfers->next;
1230
1231
    is($transfer_item->get_transfer->branchtransfer_id,
1232
       $item_with_branchtransfers->get_transfer->branchtransfer_id,
1233
       'an active transfer produces same branchtransfer_id for both methods');
1234
1235
    $schema->storage->txn_rollback;
1236
};
1237
1179
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
1238
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
1180
    plan tests => 3;
1239
    plan tests => 3;
1181
1240
1182
- 

Return to bug 34639