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

(-)a/t/db_dependent/Koha/Item.t (-2 / +68 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
        { prefetch        => ['current_branchtransfers'] }
1203
    );
1204
1205
    my $item_with_branchtransfers = $current_branchtransfers->next;
1206
1207
    is(
1208
        $transfer_item->itemnumber,
1209
        $item_with_branchtransfers->itemnumber,
1210
        'following two items are the same'
1211
    );
1212
1213
    # following two tests should produce the same result
1214
    is(
1215
        $transfer_item->get_transfer,
1216
        undef,
1217
        'Koha::Item->get_transfer returns undef with no active transfers'
1218
    );
1219
    is(
1220
        $item_with_branchtransfers->get_transfer, undef,
1221
        'prefetched result->get_transfer returns undef with no active transfers'
1222
    );
1223
1224
    $transfer->set(
1225
        {
1226
            datearrived => undef,
1227
        }
1228
    )->store;
1229
1230
    $current_branchtransfers = Koha::Items->search(
1231
        { 'me.itemnumber' => $transfer_item->itemnumber },
1232
        { prefetch        => ['current_branchtransfers'] }
1233
    );
1234
1235
    $item_with_branchtransfers = $current_branchtransfers->next;
1236
1237
    is(
1238
        $transfer_item->get_transfer->branchtransfer_id,
1239
        $item_with_branchtransfers->get_transfer->branchtransfer_id,
1240
        'an active transfer produces same branchtransfer_id for both methods'
1241
    );
1242
1243
    $schema->storage->txn_rollback;
1244
};
1245
1179
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
1246
subtest 'Tests for relationship between item and item_orders via aqorders_item' => sub {
1180
    plan tests => 3;
1247
    plan tests => 3;
1181
1248
1182
- 

Return to bug 34639