Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 19; |
20 |
use Test::More tests => 20; |
21 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
22 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
23 |
|
23 |
|
Lines 173-175
$recall = Koha::Recalls->find( $recall->recall_id );
Link Here
|
173 |
ok( $recall->fulfilled, "Recall fulfilled with move_recall" ); |
173 |
ok( $recall->fulfilled, "Recall fulfilled with move_recall" ); |
174 |
|
174 |
|
175 |
$schema->storage->txn_rollback(); |
175 |
$schema->storage->txn_rollback(); |
176 |
- |
176 |
|
|
|
177 |
subtest 'filter_by_current() and filter_by_finished() tests' => sub { |
178 |
|
179 |
plan tests => 10; |
180 |
|
181 |
$schema->storage->txn_begin; |
182 |
|
183 |
my $in_transit = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'in_transit' } } ); |
184 |
my $overdue = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'overdue' } } ); |
185 |
my $requested = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'requested' } } ); |
186 |
my $waiting = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'waiting' } } ); |
187 |
my $cancelled = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'cancelled' } } ); |
188 |
my $expired = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'expired' } } ); |
189 |
my $fulfilled = $builder->build_object( { class => 'Koha::Recalls', value => { status => 'fulfilled' } } ); |
190 |
|
191 |
my $recalls = Koha::Recalls->search( |
192 |
{ |
193 |
recall_id => [ |
194 |
$in_transit->id, |
195 |
$overdue->id, |
196 |
$requested->id, |
197 |
$waiting->id, |
198 |
$cancelled->id, |
199 |
$expired->id, |
200 |
$fulfilled->id, |
201 |
] |
202 |
}, |
203 |
{ order_by => [ 'recall_id' ] } |
204 |
); |
205 |
|
206 |
is( $recalls->count, 7, 'Resultset count is correct' ); |
207 |
|
208 |
my $current_recalls = $recalls->filter_by_current; |
209 |
is( $current_recalls->count, 4, 'Current recalls count correct' ); |
210 |
|
211 |
is( $current_recalls->next->status, 'in_transit', 'Resultset correctly includes in_transit recall'); |
212 |
is( $current_recalls->next->status, 'overdue', 'Resultset correctly includes overdue recall'); |
213 |
is( $current_recalls->next->status, 'requested', 'Resultset correctly includes requested recall'); |
214 |
is( $current_recalls->next->status, 'waiting', 'Resultset correctly includes waiting recall'); |
215 |
|
216 |
my $finished_recalls = $recalls->filter_by_finished; |
217 |
is( $finished_recalls->count, 3, 'Finished recalls count correct' ); |
218 |
|
219 |
is( $finished_recalls->next->status, 'cancelled', 'Resultset correctly includes cancelled recall'); |
220 |
is( $finished_recalls->next->status, 'expired', 'Resultset correctly includes expired recall'); |
221 |
is( $finished_recalls->next->status, 'fulfilled', 'Resultset correctly includes fulfilled recall'); |
222 |
|
223 |
$schema->storage->txn_rollback; |
224 |
}; |