Bugzilla – Attachment 106627 Details for
Bug 25850
CalcDateDue freezes with 'useDaysMode' set to 'Dayweek' and the due date lands on a Sunday
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25850: Regression Test
Bug-25850-Regression-Test.patch (text/plain), 2.97 KB, created by
Nick Clemens (kidclamp)
on 2020-07-07 12:07:04 UTC
(
hide
)
Description:
Bug 25850: Regression Test
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-07-07 12:07:04 UTC
Size:
2.97 KB
patch
obsolete
>From 021403da0f488ffc533016a4f7c6d03d01c43821 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 26 Jun 2020 16:52:50 +0100 >Subject: [PATCH] Bug 25850: Regression Test > >This patch adds a unit test to test for an infinite loop as highlighted >by the bug. > >Test plan >1/ Run the test before applying the fix >2/ The test should fail for 'Sundays' >3/ Apply the subsquent patch >4/ Re-run the test >5/ It should now pass > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Calendar.t | 60 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 59 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Calendar.t b/t/db_dependent/Calendar.t >index 56b202b498..99db1b1ea3 100644 >--- a/t/db_dependent/Calendar.t >+++ b/t/db_dependent/Calendar.t >@@ -17,8 +17,10 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Time::Fake; >+ >+use t::lib::Mocks; > use t::lib::TestBuilder; > > use DateTime; >@@ -332,4 +334,60 @@ subtest 'is_holiday' => sub { > }; > }; > >+subtest 'get_push_amt' => sub { >+ plan tests => 1; >+ >+ t::lib::Mocks::mock_preference('useDaysMode', 'Dayweek'); >+ >+ subtest 'weekday holidays' => sub { >+ plan tests => 7; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $day = DateTime->now(); >+ my $dow = scalar $day->day_of_week; >+ $dow = 0 if $dow == 7; >+ >+ # Closed this day of the week >+ my $dbh = C4::Context->dbh; >+ $dbh->do( >+ q| >+ INSERT INTO repeatable_holidays (branchcode,weekday,day,month,title,description) >+ VALUES ( ?, ?, NULL, NULL, ?, '' ) >+ |, undef, $library->branchcode, $dow, "TEST" >+ ); >+ >+ # Iterate 7 days >+ my $sth = $dbh->prepare( >+"UPDATE repeatable_holidays SET weekday = ? WHERE branchcode = ? AND title = 'TEST'" >+ ); >+ for my $i ( 0 .. 6 ) { >+ my $calendar = >+ Koha::Calendar->new( branchcode => $library->branchcode, days_mode => 'Dayweek' ); >+ >+ my $npa; >+ eval { >+ local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required >+ alarm 2; >+ $npa = $calendar->next_open_days( $day, 0 ); >+ alarm 0; >+ }; >+ if ($@) { >+ die unless $@ eq "alarm\n"; # propagate unexpected errors >+ # timed out >+ ok(0, "next_push_amt succeeded for ".$day->day_name()." weekday holiday"); >+ } >+ else { >+ ok($npa, "next_push_amt succeeded for ".$day->day_name()." weekday holiday"); >+ } >+ >+ # Increment the date and holiday day >+ $day->add( days => 1 ); >+ $dow++; >+ $dow = 0 if $dow == 7; >+ $sth->execute( $dow, $library->branchcode ); >+ } >+ }; >+}; >+ > $schema->storage->txn_rollback(); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25850
:
106207
|
106346
|
106347
|
106348
|
106381
|
106382
|
106383
|
106384
|
106626
| 106627 |
106628
|
106629
|
106630