Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
|
23 |
|
24 |
use Koha::Item::Transfer; |
24 |
use Koha::Item::Transfer; |
25 |
use Koha::Item::Transfers; |
25 |
use Koha::Item::Transfers; |
Lines 27-32
use Koha::Database;
Link Here
|
27 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
28 |
|
28 |
|
29 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
|
|
30 |
use t::lib::Dates; |
30 |
|
31 |
|
31 |
my $schema = Koha::Database->new->schema; |
32 |
my $schema = Koha::Database->new->schema; |
32 |
$schema->storage->txn_begin; |
33 |
$schema->storage->txn_begin; |
Lines 66-68
is( $retrieved_transfer_1->itemnumber, $new_transfer_1->itemnumber, 'Find a tran
Link Here
|
66 |
|
67 |
|
67 |
$schema->storage->txn_rollback; |
68 |
$schema->storage->txn_rollback; |
68 |
|
69 |
|
69 |
- |
70 |
subtest 'daterequested tests' => sub { |
|
|
71 |
|
72 |
plan tests => 3; |
73 |
|
74 |
$schema->storage->txn_begin; |
75 |
my $library_from = $builder->build( { source => 'Branch' } ); |
76 |
my $library_to = $builder->build( { source => 'Branch' } ); |
77 |
my $item = $builder->build( |
78 |
{ |
79 |
source => 'Item', |
80 |
value => { |
81 |
holding_branch => $library_from->{branchcode}, |
82 |
homebranch => $library_to->{branchcode} |
83 |
} |
84 |
} |
85 |
); |
86 |
|
87 |
my $now = dt_from_string; |
88 |
my $transfer = Koha::Item::Transfer->new( |
89 |
{ |
90 |
itemnumber => $item->{itemnumber}, |
91 |
frombranch => $library_from->{branchcode}, |
92 |
tobranch => $library_to->{branchcode} |
93 |
} |
94 |
)->store; |
95 |
$transfer->discard_changes; |
96 |
|
97 |
ok( $transfer->daterequested, 'daterequested set on creation' ); |
98 |
is( t::lib::Dates::compare( $transfer->daterequested, $now ), |
99 |
0, 'daterequested was set correctly' ); |
100 |
|
101 |
my $new_date = $now->clone->add( hours => 1 ); |
102 |
$transfer->set({ datesent => $new_date })->store; |
103 |
$transfer->discard_changes; |
104 |
|
105 |
is( t::lib::Dates::compare( $transfer->daterequested, $now ), |
106 |
0, 'daterequested is not updated when other fields are updated' ); |
107 |
|
108 |
$schema->storage->txn_rollback; |
109 |
}; |