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 => 1; |
23 |
|
23 |
|
24 |
use Koha::Bookings; |
24 |
use Koha::Bookings; |
25 |
use Koha::Database; |
25 |
use Koha::Database; |
Lines 31-94
my $schema = Koha::Database->new->schema;
Link Here
|
31 |
|
31 |
|
32 |
my $builder = t::lib::TestBuilder->new; |
32 |
my $builder = t::lib::TestBuilder->new; |
33 |
|
33 |
|
34 |
subtest 'filter_by_future' => sub { |
|
|
35 |
|
36 |
plan tests => 2; |
37 |
|
38 |
$schema->storage->txn_begin; |
39 |
|
40 |
my $biblio = $builder->build_sample_biblio; |
41 |
$builder->build_object( |
42 |
{ |
43 |
class => 'Koha::Bookings', |
44 |
value => { |
45 |
biblio_id => $biblio->biblionumber, |
46 |
start_date => dt_from_string->subtract( days => 1 )->truncate( to => 'day' ), |
47 |
end_date => undef |
48 |
} |
49 |
} |
50 |
); |
51 |
|
52 |
$builder->build_object( |
53 |
{ |
54 |
class => 'Koha::Bookings', |
55 |
value => { |
56 |
biblio_id => $biblio->biblionumber, |
57 |
start_date => dt_from_string->add( days => 1 )->truncate( to => 'day' ), |
58 |
end_date => undef |
59 |
} |
60 |
} |
61 |
); |
62 |
|
63 |
$builder->build_object( |
64 |
{ |
65 |
class => 'Koha::Bookings', |
66 |
value => { |
67 |
biblio_id => $biblio->biblionumber, |
68 |
start_date => dt_from_string->add( days => 2 )->truncate( to => 'day' ), |
69 |
end_date => undef |
70 |
} |
71 |
} |
72 |
); |
73 |
|
74 |
is( $biblio->bookings->filter_by_future->count, 2, 'There should have 2 bookings starting after now' ); |
75 |
|
76 |
$builder->build_object( |
77 |
{ |
78 |
class => 'Koha::Bookings', |
79 |
value => { |
80 |
biblio_id => $biblio->biblionumber, |
81 |
start_date => dt_from_string->truncate( to => 'day' ), |
82 |
end_date => undef |
83 |
} |
84 |
} |
85 |
); |
86 |
|
87 |
is( $biblio->bookings->filter_by_future->count, 2, 'Current day is not considered future' ); |
88 |
|
89 |
$schema->storage->txn_rollback; |
90 |
}; |
91 |
|
92 |
subtest 'filter_by_active' => sub { |
34 |
subtest 'filter_by_active' => sub { |
93 |
|
35 |
|
94 |
plan tests => 5; |
36 |
plan tests => 5; |
95 |
- |
|
|