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

(-)a/Koha/Item.pm (-2 lines)
Lines 459-466 Note: Transfers are retrieved in a Modified FIFO (First In First Out) order Link Here
459
whereby the most recently sent, but not recieved, transfer will be returned
459
whereby the most recently sent, but not recieved, transfer will be returned
460
if it exists, otherwise the oldest unsatisfied transfer will be returned.
460
if it exists, otherwise the oldest unsatisfied transfer will be returned.
461
461
462
FIXME: Add Tests for FIFO functionality
463
464
=cut
462
=cut
465
463
466
sub get_transfer {
464
sub get_transfer {
(-)a/t/db_dependent/Koha/Items.t (-8 / +56 lines)
Lines 811-833 subtest 'store' => sub { Link Here
811
};
811
};
812
812
813
subtest 'get_transfer' => sub {
813
subtest 'get_transfer' => sub {
814
    plan tests => 3;
814
    plan tests => 6;
815
815
816
    my $transfer = $new_item_1->get_transfer();
816
    my $transfer = $new_item_1->get_transfer();
817
    is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' );
817
    is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' );
818
818
819
    my $library_to = $builder->build( { source => 'Branch' } );
819
    my $library_to = $builder->build( { source => 'Branch' } );
820
820
821
    C4::Circulation::transferbook({
821
    my $transfer_1 = $builder->build_object(
822
        from_branch => $new_item_1->holdingbranch,
822
        {
823
        to_branch => $library_to->{branchcode},
823
            class => 'Koha::Item::Transfers',
824
        barcode => $new_item_1->barcode,
824
            value => {
825
    });
825
                itemnumber    => $new_item_1->itemnumber,
826
                frombranch    => $new_item_1->holdingbranch,
827
                tobranch      => $library_to->{branchcode},
828
                reason        => 'Manual',
829
                datesent      => undef,
830
                datearrived   => undef,
831
                daterequested => \'NOW()'
832
            }
833
        }
834
    );
826
835
827
    $transfer = $new_item_1->get_transfer();
836
    $transfer = $new_item_1->get_transfer();
828
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
837
    is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' );
829
838
830
    is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' );
839
    my $transfer_2 = $builder->build_object(
840
        {
841
            class => 'Koha::Item::Transfers',
842
            value => {
843
                itemnumber  => $new_item_1->itemnumber,
844
                frombranch  => $new_item_1->holdingbranch,
845
                tobranch    => $library_to->{branchcode},
846
                reason      => 'Manual',
847
                datesent    => undef,
848
                datearrived => undef,
849
                daterequested => \'NOW()'
850
            }
851
        }
852
    );
853
854
    $transfer = $new_item_1->get_transfer();
855
    is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the oldest transfer request');
856
857
    $transfer_2->datesent(\'NOW()')->store;
858
    $transfer = $new_item_1->get_transfer();
859
    is( $transfer->branchtransfer_id, $transfer_2->branchtransfer_id, 'Koha::Item->get_transfer returns the in_transit transfer');
860
861
    my $transfer_3 = $builder->build_object(
862
        {
863
            class => 'Koha::Item::Transfers',
864
            value => {
865
                itemnumber  => $new_item_1->itemnumber,
866
                frombranch  => $new_item_1->holdingbranch,
867
                tobranch    => $library_to->{branchcode},
868
                reason      => 'Manual',
869
                datesent    => undef,
870
                datearrived => undef,
871
                daterequested => \'NOW()'
872
            }
873
        }
874
    );
875
876
    $transfer_2->datearrived(\'NOW()')->store;
877
    $transfer = $new_item_1->get_transfer();
878
    is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the next queued transfer');
879
    is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer returns the right items transfer' );
831
};
880
};
832
881
833
subtest 'holds' => sub {
882
subtest 'holds' => sub {
834
- 

Return to bug 25755