|
Lines 23-29
use Koha::Database;
Link Here
|
| 23 |
|
23 |
|
| 24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
| 25 |
|
25 |
|
| 26 |
use Test::More tests => 2; |
26 |
use Test::More tests => 3; |
| 27 |
use Test::Exception; |
27 |
use Test::Exception; |
| 28 |
|
28 |
|
| 29 |
my $schema = Koha::Database->new->schema; |
29 |
my $schema = Koha::Database->new->schema; |
|
Lines 112-114
subtest 'transit tests' => sub {
Link Here
|
| 112 |
|
112 |
|
| 113 |
$schema->storage->txn_rollback; |
113 |
$schema->storage->txn_rollback; |
| 114 |
}; |
114 |
}; |
| 115 |
- |
115 |
|
|
|
116 |
subtest 'receive tests' => sub { |
| 117 |
plan tests => 5; |
| 118 |
|
| 119 |
$schema->storage->txn_begin; |
| 120 |
|
| 121 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 122 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 123 |
my $item = $builder->build_sample_item( |
| 124 |
{ |
| 125 |
homebranch => $library1->branchcode, |
| 126 |
holdingbranch => $library2->branchcode, |
| 127 |
datelastseen => undef |
| 128 |
} |
| 129 |
); |
| 130 |
|
| 131 |
my $transfer = $builder->build_object( |
| 132 |
{ |
| 133 |
class => 'Koha::Item::Transfers', |
| 134 |
value => { |
| 135 |
itemnumber => $item->itemnumber, |
| 136 |
frombranch => $library2->branchcode, |
| 137 |
tobranch => $library1->branchcode, |
| 138 |
datearrived => undef, |
| 139 |
reason => 'Manual' |
| 140 |
} |
| 141 |
} |
| 142 |
); |
| 143 |
is( ref($transfer), 'Koha::Item::Transfer', 'Mock transfer added' ); |
| 144 |
|
| 145 |
# Item checked out should result in failure |
| 146 |
my $checkout = $builder->build_object( |
| 147 |
{ |
| 148 |
class => 'Koha::Checkouts', |
| 149 |
value => { |
| 150 |
itemnumber => $item->itemnumber |
| 151 |
} |
| 152 |
} |
| 153 |
); |
| 154 |
is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' ); |
| 155 |
|
| 156 |
throws_ok { $transfer->receive() } |
| 157 |
'Koha::Exceptions::Item::Transfer::Out', |
| 158 |
'Exception thrown if item is checked out'; |
| 159 |
|
| 160 |
$checkout->delete; |
| 161 |
|
| 162 |
# Transit state set |
| 163 |
$transfer->discard_changes; |
| 164 |
$transfer->receive(); |
| 165 |
ok( $transfer->datearrived, 'Receipt set the datearrived for the transfer' ); |
| 166 |
|
| 167 |
# Last seen |
| 168 |
ok( $item->datelastseen, 'Receipt set item datelastseen date' ); |
| 169 |
|
| 170 |
$schema->storage->txn_rollback; |
| 171 |
}; |