From 74afa350a986f42705406c528ed5eb5ef629716b Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 7 Aug 2025 09:17:46 +0000 Subject: [PATCH] Bug 17656: (QA follow-up) fix tests --- t/Serials/IssueNumber.t | 23 ++++++++++--------- t/db_dependent/Koha/Subscription.t | 2 +- .../Koha/Subscription/GuessEnddate.t | 0 .../Koha/Subscription/Irregularities.t | 15 ++++++++---- .../Serials/SubscriptionIrregularity.t | 0 5 files changed, 23 insertions(+), 17 deletions(-) mode change 100644 => 100755 t/Serials/IssueNumber.t mode change 100644 => 100755 t/db_dependent/Koha/Subscription/GuessEnddate.t mode change 100644 => 100755 t/db_dependent/Koha/Subscription/Irregularities.t mode change 100644 => 100755 t/db_dependent/Serials/SubscriptionIrregularity.t diff --git a/t/Serials/IssueNumber.t b/t/Serials/IssueNumber.t old mode 100644 new mode 100755 index d9cd65331bd..1dbe8b8b3fb --- a/t/Serials/IssueNumber.t +++ b/t/Serials/IssueNumber.t @@ -17,8 +17,9 @@ use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 9; use Test::Warn; +use Test::Exception; BEGIN { use_ok('C4::Serials'); @@ -26,22 +27,22 @@ BEGIN { my $dt = DateTime->new( year => 2017, month => 1, day => 1 ); -eval { issue_number( '2017', 'day' ); }; -is( ref($@), 'Koha::Exceptions::WrongParameter' ); -is( $@, 'Date passed to issue_number is not a valid DateTime object' ); +throws_ok { C4::Serials::issue_number( '2017', 'day' ) } +'Koha::Exceptions::WrongParameter', + 'Date passed to issue_number is not a valid DateTime object'; -is( issue_number( $dt, 'day' ), 7, '2017-01-01 is the seventh day of week' ); +is( C4::Serials::issue_number( $dt, 'day' ), 7, '2017-01-01 is the seventh day of week' ); -is( issue_number( $dt, 'week' ), 52, '2017-01-01 is the week #52 of the year' ); +is( C4::Serials::issue_number( $dt, 'week' ), 52, '2017-01-01 is the week #52 of the year' ); -is( issue_number( $dt, 'month' ), 1, '2017-01-01 is the first month of the year' ); +is( C4::Serials::issue_number( $dt, 'month' ), 1, '2017-01-01 is the first month of the year' ); $dt = DateTime->new( year => 2022, month => 9, day => 17 ); -is( issue_number( $dt, 'day' ), 6, '2022-09-17 is the sixth day of week' ); +is( C4::Serials::issue_number( $dt, 'day' ), 6, '2022-09-17 is the sixth day of week' ); -is( issue_number( $dt, 'week' ), 37, '2022-09-17 is the week #37 of the year' ); +is( C4::Serials::issue_number( $dt, 'week' ), 37, '2022-09-17 is the week #37 of the year' ); -is( issue_number( $dt, 'month' ), 9, '2022-09-17 is the ninth month of the year' ); +is( C4::Serials::issue_number( $dt, 'month' ), 9, '2022-09-17 is the ninth month of the year' ); -is( issue_number( $dt, 'foo' ), 0, 'issue_number return 0 for others issue type' ); +is( C4::Serials::issue_number( $dt, 'foo' ), 0, 'issue_number return 0 for others issue type' ); diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t index 45f40546513..beec6f81975 100755 --- a/t/db_dependent/Koha/Subscription.t +++ b/t/db_dependent/Koha/Subscription.t @@ -20,7 +20,7 @@ use Modern::Perl; use Test::NoWarnings; -use Test::More tests => 11; +use Test::More tests => 12; use Koha::Database; use Koha::Subscription; diff --git a/t/db_dependent/Koha/Subscription/GuessEnddate.t b/t/db_dependent/Koha/Subscription/GuessEnddate.t old mode 100644 new mode 100755 diff --git a/t/db_dependent/Koha/Subscription/Irregularities.t b/t/db_dependent/Koha/Subscription/Irregularities.t old mode 100644 new mode 100755 index 122d2dae399..b71ffe3b5f4 --- a/t/db_dependent/Koha/Subscription/Irregularities.t +++ b/t/db_dependent/Koha/Subscription/Irregularities.t @@ -85,7 +85,7 @@ my $subscription = $builder->build( firstacquidate => '2018-05-07', irregularity => '3;4', permanent_irregularity => '3;4', - numberpattern => 7, + numberpattern => $number_pattern->{id}, enddate => '2018-05-13', closed => 0 } @@ -182,10 +182,15 @@ $builder->build( } ); -ReNewSubscription( - $subscription->{subscriptionid}, undef, - $subscription->{enddate}, $subscription->{numberlength}, - $subscription->{weeklength}, $subscription->{monthlength}, +C4::Serials::ReNewSubscription( + { + subscriptionid => $subscription->{subscriptionid}, + user => undef, + startdate => $subscription->{enddate}, + numberlength => $subscription->{numberlength}, + weeklength => $subscription->{weeklength}, + monthlength => $subscription->{monthlength}, + } ); my $s = Koha::Subscriptions->find( $subscription->{subscriptionid} ); diff --git a/t/db_dependent/Serials/SubscriptionIrregularity.t b/t/db_dependent/Serials/SubscriptionIrregularity.t old mode 100644 new mode 100755 -- 2.39.5