Lines 199-205
subtest 'hours_between | days_between' => sub {
Link Here
|
199 |
my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); |
199 |
my $calendar = Koha::Calendar->new( branchcode => $library->branchcode ); |
200 |
|
200 |
|
201 |
subtest 'Same hours' => sub { |
201 |
subtest 'Same hours' => sub { |
202 |
plan tests => 10; |
202 |
plan tests => 12; |
203 |
|
203 |
|
204 |
my ( $diff_hours, $diff_days ); |
204 |
my ( $diff_hours, $diff_days ); |
205 |
|
205 |
|
Lines 209-218
subtest 'hours_between | days_between' => sub {
Link Here
|
209 |
$diff_days = $calendar->days_between( $now, $nov_6)->delta_days; |
209 |
$diff_days = $calendar->days_between( $now, $nov_6)->delta_days; |
210 |
is( $diff_days, 0, '' ); # FIXME Is this really should be 0? |
210 |
is( $diff_days, 0, '' ); # FIXME Is this really should be 0? |
211 |
|
211 |
|
|
|
212 |
# Between 6th and 7th (This case should never happen in real code, one cannot issue on a closed day) |
213 |
$diff_hours = $calendar->hours_between( $nov_6, $nov_7 )->hours; |
214 |
is( $diff_hours, 0 * 24, '' ); # FIXME Is this really should be 0? |
215 |
$diff_days = $calendar->days_between( $nov_6, $nov_7 )->delta_days; |
216 |
is( $diff_days, 0, '' ); # FIXME Is this really should be 0? |
217 |
|
212 |
# Between 5th and 7th |
218 |
# Between 5th and 7th |
213 |
$diff_hours = $calendar->hours_between( $now, $nov_7 )->hours; |
219 |
$diff_hours = $calendar->hours_between( $now, $nov_7 )->hours; |
214 |
is( $diff_hours, 2 * 24 - 1 * 24, '' ); |
220 |
is( $diff_hours, 2 * 24 - 1 * 24, '' ); |
215 |
$diff_days = $calendar->days_between( $now, $nov_7)->delta_days; |
221 |
$diff_days = $calendar->days_between( $now, $nov_7 )->delta_days; |
216 |
is( $diff_days, 2 - 1, '' ); |
222 |
is( $diff_days, 2 - 1, '' ); |
217 |
|
223 |
|
218 |
# Between 5th and 12th |
224 |
# Between 5th and 12th |
Lines 235-241
subtest 'hours_between | days_between' => sub {
Link Here
|
235 |
}; |
241 |
}; |
236 |
|
242 |
|
237 |
subtest 'Different hours' => sub { |
243 |
subtest 'Different hours' => sub { |
238 |
plan tests => 11; |
244 |
plan tests => 14; |
239 |
|
245 |
|
240 |
my ( $diff_hours, $diff_days ); |
246 |
my ( $diff_hours, $diff_days ); |
241 |
|
247 |
|
Lines 249-254
subtest 'hours_between | days_between' => sub {
Link Here
|
249 |
$duration = $calendar->days_between( $now, $nov_6->clone->subtract(hours => 3) ); |
255 |
$duration = $calendar->days_between( $now, $nov_6->clone->subtract(hours => 3) ); |
250 |
is( $duration->hours, abs(0), '' ); # FIXME Is this correct? |
256 |
is( $duration->hours, abs(0), '' ); # FIXME Is this correct? |
251 |
|
257 |
|
|
|
258 |
# Between 6th and 7th (This case should never happen in real code, one cannot issue on a closed day) |
259 |
$duration = $calendar->hours_between( $nov_6, $nov_7->clone->subtract(hours => 3) ); |
260 |
is( $duration->hours, abs(0 * 24 - 3), '' ); # FIXME $duration->hours always return a abs |
261 |
is( $duration->is_negative, 1, ); # FIXME Do really test for that case in our calls to hours_between? |
262 |
$duration = $calendar->days_between( $nov_6, $nov_7->clone->subtract(hours => 3) ); |
263 |
is( $duration->hours, abs(0), '' ); # FIXME Is this correct? |
264 |
|
252 |
# Between 5th and 7th |
265 |
# Between 5th and 7th |
253 |
$diff_hours = $calendar->hours_between( $now, $nov_7->clone->subtract(hours => 3) )->hours; |
266 |
$diff_hours = $calendar->hours_between( $now, $nov_7->clone->subtract(hours => 3) )->hours; |
254 |
is( $diff_hours, 2 * 24 - 1 * 24 - 3, '' ); |
267 |
is( $diff_hours, 2 * 24 - 1 * 24 - 3, '' ); |
255 |
- |
|
|