|
Lines 23-28
use Test::More tests => 1;
Link Here
|
| 23 |
|
23 |
|
| 24 |
use C4::Reserves; |
24 |
use C4::Reserves; |
| 25 |
|
25 |
|
|
|
26 |
use Koha::DateUtils qw( dt_from_string ); |
| 26 |
use Koha::Biblios; |
27 |
use Koha::Biblios; |
| 27 |
use Koha::Patrons; |
28 |
use Koha::Patrons; |
| 28 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
|
Lines 43-55
my $biblioitem = $schema->resultset('Biblioitem')->new(
Link Here
|
| 43 |
} |
44 |
} |
| 44 |
)->insert(); |
45 |
)->insert(); |
| 45 |
|
46 |
|
| 46 |
subtest 'holds' => sub { |
47 |
subtest 'holds + holds_placed_before_today' => sub { |
| 47 |
plan tests => 3; |
48 |
plan tests => 5; |
| 48 |
C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber ); |
49 |
C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber ); |
| 49 |
my $holds = $biblio->holds; |
50 |
my $holds = $biblio->holds; |
| 50 |
is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' ); |
51 |
is( ref($holds), 'Koha::Holds', '->holds should return a Koha::Holds object' ); |
| 51 |
is( $holds->count, 1, '->holds should only return 1 hold' ); |
52 |
is( $holds->count, 1, '->holds should only return 1 hold' ); |
| 52 |
is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' ); |
53 |
is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' ); |
|
|
54 |
$holds->delete; |
| 55 |
|
| 56 |
# Add a hold in the future |
| 57 |
C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber, undef, undef, dt_from_string->add( days => 2 ) ); |
| 58 |
$holds = $biblio->holds; |
| 59 |
is( $holds->count, 1, '->holds should return future holds' ); |
| 60 |
$holds = $biblio->holds_placed_before_today; |
| 61 |
is( $holds->count, 0, '->holds_placed_before_today should not return future holds' ); |
| 62 |
$holds->delete; |
| 63 |
|
| 53 |
}; |
64 |
}; |
| 54 |
|
65 |
|
| 55 |
$schema->storage->txn_rollback; |
66 |
$schema->storage->txn_rollback; |
| 56 |
- |
|
|