|
Lines 17-24
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 10; |
20 |
use Test::More tests => 9; |
| 21 |
use Test::Warn; |
21 |
use Test::Warn; |
|
|
22 |
use Test::Exception; |
| 22 |
|
23 |
|
| 23 |
BEGIN { |
24 |
BEGIN { |
| 24 |
use_ok('C4::Serials'); |
25 |
use_ok('C4::Serials'); |
|
Lines 26-47
BEGIN {
Link Here
|
| 26 |
|
27 |
|
| 27 |
my $dt = DateTime->new( year => 2017, month => 1, day => 1 ); |
28 |
my $dt = DateTime->new( year => 2017, month => 1, day => 1 ); |
| 28 |
|
29 |
|
| 29 |
eval { issue_number( '2017', 'day' ); }; |
30 |
throws_ok { C4::Serials::issue_number( '2017', 'day' ) } |
| 30 |
is( ref($@), 'Koha::Exceptions::WrongParameter' ); |
31 |
'Koha::Exceptions::WrongParameter', |
| 31 |
is( $@, 'Date passed to issue_number is not a valid DateTime object' ); |
32 |
'Date passed to issue_number is not a valid DateTime object'; |
| 32 |
|
33 |
|
| 33 |
is( issue_number( $dt, 'day' ), 7, '2017-01-01 is the seventh day of week' ); |
34 |
is( C4::Serials::issue_number( $dt, 'day' ), 7, '2017-01-01 is the seventh day of week' ); |
| 34 |
|
35 |
|
| 35 |
is( issue_number( $dt, 'week' ), 52, '2017-01-01 is the week #52 of the year' ); |
36 |
is( C4::Serials::issue_number( $dt, 'week' ), 52, '2017-01-01 is the week #52 of the year' ); |
| 36 |
|
37 |
|
| 37 |
is( issue_number( $dt, 'month' ), 1, '2017-01-01 is the first month of the year' ); |
38 |
is( C4::Serials::issue_number( $dt, 'month' ), 1, '2017-01-01 is the first month of the year' ); |
| 38 |
|
39 |
|
| 39 |
$dt = DateTime->new( year => 2022, month => 9, day => 17 ); |
40 |
$dt = DateTime->new( year => 2022, month => 9, day => 17 ); |
| 40 |
|
41 |
|
| 41 |
is( issue_number( $dt, 'day' ), 6, '2022-09-17 is the sixth day of week' ); |
42 |
is( C4::Serials::issue_number( $dt, 'day' ), 6, '2022-09-17 is the sixth day of week' ); |
| 42 |
|
43 |
|
| 43 |
is( issue_number( $dt, 'week' ), 37, '2022-09-17 is the week #37 of the year' ); |
44 |
is( C4::Serials::issue_number( $dt, 'week' ), 37, '2022-09-17 is the week #37 of the year' ); |
| 44 |
|
45 |
|
| 45 |
is( issue_number( $dt, 'month' ), 9, '2022-09-17 is the ninth month of the year' ); |
46 |
is( C4::Serials::issue_number( $dt, 'month' ), 9, '2022-09-17 is the ninth month of the year' ); |
| 46 |
|
47 |
|
| 47 |
is( issue_number( $dt, 'foo' ), 0, 'issue_number return 0 for others issue type' ); |
48 |
is( C4::Serials::issue_number( $dt, 'foo' ), 0, 'issue_number return 0 for others issue type' ); |