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

(-)a/Koha/Item/Transfer.pm (+13 lines)
Lines 82-87 sub transit { Link Here
82
82
83
    ModDateLastSeen( $self->item->itemnumber );
83
    ModDateLastSeen( $self->item->itemnumber );
84
    return $self;
84
    return $self;
85
86
}
87
88
=head3 in_transit
89
90
Boolean returning whether the transfer is in transit or waiting
91
92
=cut
93
94
sub in_transit {
95
    my ($self) = @_;
96
97
    return ( defined( $self->datesent ) && !defined( $self->datearrived ) );
85
}
98
}
86
99
87
=head3 receive
100
=head3 receive
(-)a/t/db_dependent/Koha/Item/Transfer.t (-2 / +38 lines)
Lines 20-29 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::DateUtils;
23
24
24
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
25
26
26
use Test::More tests => 3;
27
use Test::More tests => 4;
27
use Test::Exception;
28
use Test::Exception;
28
29
29
my $schema  = Koha::Database->new->schema;
30
my $schema  = Koha::Database->new->schema;
Lines 167-171 subtest 'receive tests' => sub { Link Here
167
    # Last seen
168
    # Last seen
168
    ok( $item->datelastseen, 'Receipt set item datelastseen date' );
169
    ok( $item->datelastseen, 'Receipt set item datelastseen date' );
169
170
171
    $schema->storage->txn_rollback;
172
};
173
174
subtest 'in_transit tests' => sub {
175
176
    plan tests => 3;
177
178
    $schema->storage->txn_begin;
179
180
    my $library_from = $builder->build_object( { class => 'Koha::Libraries' } );
181
    my $library_to   = $builder->build_object( { class => 'Koha::Libraries' } );
182
    my $item     = $builder->build_sample_item(
183
        {
184
            homebranch    => $library_to->branchcode,
185
            holdingbranch => $library_from->branchcode,
186
        }
187
    );
188
189
    my $transfer = Koha::Item::Transfer->new(
190
        {
191
            itemnumber    => $item->itemnumber,
192
            frombranch    => $library_from->branchcode,
193
            tobranch      => $library_to->branchcode,
194
            daterequested => dt_from_string,
195
        }
196
    )->store;
197
198
    ok( !$transfer->in_transit, 'in_transit returns false when only daterequested is defined' );
199
200
    $transfer->datesent(dt_from_string)->store;
201
    ok( $transfer->in_transit, 'in_transit returns true when datesent is defined');
202
203
    $transfer->datearrived(dt_from_string)->store;
204
    ok( !$transfer->in_transit, 'in_transit returns false when datearrived is defined');
205
206
170
    $schema->storage->txn_rollback;
207
    $schema->storage->txn_rollback;
171
};
208
};
172
- 

Return to bug 26481