Bugzilla – Attachment 156354 Details for
Bug 17015
New Koha Calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17015: Corrections for tests
Bug-17015-Corrections-for-tests.patch (text/plain), 7.11 KB, created by
Emily-Rose Francoeur
on 2023-09-28 19:35:50 UTC
(
hide
)
Description:
Bug 17015: Corrections for tests
Filename:
MIME Type:
Creator:
Emily-Rose Francoeur
Created:
2023-09-28 19:35:50 UTC
Size:
7.11 KB
patch
obsolete
>From f0b3c6a4f8e2e6cb70eb4fad1d3571a9d0464f6f Mon Sep 17 00:00:00 2001 >From: Maryse Simard <maryse.simard@inlibro.com> >Date: Thu, 18 May 2023 16:22:55 -0400 >Subject: [PATCH] Bug 17015: Corrections for tests > >--- > t/db_dependent/Circulation/CalcDateDue.t | 2 ++ > t/db_dependent/Circulation/CalcFine.t | 1 + > .../Circulation/maxsuspensiondays.t | 6 ++++ > t/db_dependent/Fines.t | 5 +++ > t/db_dependent/Hold.t | 1 + > t/db_dependent/Holds/WaitingReserves.t | 1 + > .../Reserves/CancelExpiredReserves.t | 1 + > t/lib/TestBuilder.pm | 32 ++++++++++++++++++- > 8 files changed, 48 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t >index 351e360941..5234dede0e 100755 >--- a/t/db_dependent/Circulation/CalcDateDue.t >+++ b/t/db_dependent/Circulation/CalcDateDue.t >@@ -38,6 +38,8 @@ my $issuelength = 10; > my $renewalperiod = 5; > my $lengthunit = 'days'; > >+$builder->fill_discrete_calendar({ branchcode => $branchcode, start_date => '2013-01-01', days => 365 }); >+ > Koha::CirculationRules->search()->delete(); > Koha::CirculationRules->set_rules( > { >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >index d372d17339..17082f4dca 100755 >--- a/t/db_dependent/Circulation/CalcFine.t >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -28,6 +28,7 @@ my $branch = $builder->build( > source => 'Branch', > } > ); >+$builder->fill_discrete_calendar({ branchcode => $branch->{branchcode}, start_date => '2000-01-01' }); > > my $category = $builder->build( > { >diff --git a/t/db_dependent/Circulation/maxsuspensiondays.t b/t/db_dependent/Circulation/maxsuspensiondays.t >index 81e6e03692..95e060f292 100755 >--- a/t/db_dependent/Circulation/maxsuspensiondays.t >+++ b/t/db_dependent/Circulation/maxsuspensiondays.t >@@ -125,6 +125,9 @@ subtest "suspension_chargeperiod" => sub { > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $item = $builder->build_sample_item; > >+ $builder->fill_discrete_calendar({ branchcode => $patron->{branchcode}, days => 365 }); >+ $builder->fill_discrete_calendar({ branchcode => $item->homebranch, days => 365 }); >+ > my $last_year = dt_from_string->clone->subtract( years => 1 ); > my $today = dt_from_string; > my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron, $item, $last_year, $today ); >@@ -151,6 +154,9 @@ subtest "maxsuspensiondays" => sub { > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $item = $builder->build_sample_item; > >+ $builder->fill_discrete_calendar({ branchcode => $patron->{branchcode}, days => 365 }); >+ $builder->fill_discrete_calendar({ branchcode => $item->homebranch, days => 365 }); >+ > my $last_year = dt_from_string->clone->subtract( years => 1 ); > my $today = dt_from_string; > my $new_debar_dt = C4::Circulation::_calculate_new_debar_dt( $patron, $item, $last_year, $today ); >diff --git a/t/db_dependent/Fines.t b/t/db_dependent/Fines.t >index b604a3374a..9e8d2af91a 100755 >--- a/t/db_dependent/Fines.t >+++ b/t/db_dependent/Fines.t >@@ -7,6 +7,7 @@ use C4::Overdues qw( CalcFine ); > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > >+use t::lib::TestBuilder; > use Test::More tests => 5; > > my $schema = Koha::Database->new->schema; >@@ -31,6 +32,10 @@ my $issuingrule = Koha::CirculationRules->set_rules( > } > ); > >+my $builder = t::lib::TestBuilder->new(); >+$builder->fill_discrete_calendar({ branchcode => '' }); >+$builder->fill_discrete_calendar({ branchcode => '', start_date => '2000-01-01' }); >+ > ok( $issuingrule, 'Issuing rule created' ); > > my $period_start = dt_from_string('2000-01-01'); >diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t >index b96a917773..279ff04465 100755 >--- a/t/db_dependent/Hold.t >+++ b/t/db_dependent/Hold.t >@@ -77,6 +77,7 @@ my $hold = Koha::Hold->new( > ); > $hold->store(); > >+$builder->fill_discrete_calendar({ branchcode => $branches[1]->{branchcode}, start_date => '2017-01-01', days => dt_from_string->delta_days( dt_from_string( '2017-01-01' ) )->in_units( 'days') }); > my $b1_cal = Koha::DiscreteCalendar->new({ branchcode => $branches[1]->{branchcode} }); > my $holiday = dt_from_string('2017-01-02', 'iso'); > $b1_cal->edit_holiday({ >diff --git a/t/db_dependent/Holds/WaitingReserves.t b/t/db_dependent/Holds/WaitingReserves.t >index 73b025075a..f664c5a578 100755 >--- a/t/db_dependent/Holds/WaitingReserves.t >+++ b/t/db_dependent/Holds/WaitingReserves.t >@@ -35,6 +35,7 @@ $builder->build({ > }, > }); > >+$builder->fill_discrete_calendar({ branchcode => 'LIB1' }); > my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' }); > > $builder->build({ >diff --git a/t/db_dependent/Reserves/CancelExpiredReserves.t b/t/db_dependent/Reserves/CancelExpiredReserves.t >index b8d8aaeb8d..4bff1f1767 100755 >--- a/t/db_dependent/Reserves/CancelExpiredReserves.t >+++ b/t/db_dependent/Reserves/CancelExpiredReserves.t >@@ -81,6 +81,7 @@ subtest 'CancelExpiredReserves tests incl. holidays' => sub { > }); > > Koha::Caches->get_instance()->flush_all(); >+ $builder->fill_discrete_calendar({ branchcode => 'LIB1 '}); > my $calendar = Koha::DiscreteCalendar->new({ branchcode => 'LIB1' })->edit_holiday({ > title => "My holiday", > holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 89331e96d0..213c0d7205 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -6,7 +6,7 @@ use Koha::Database qw( schema ); > use C4::Biblio qw( AddBiblio ); > use Koha::Biblios qw( _type ); > use Koha::Items qw( _type ); >-use Koha::DateUtils qw( dt_from_string ); >+use Koha::DateUtils qw( dt_from_string output_pref ); > > use Bytes::Random::Secure; > use Carp qw( carp ); >@@ -146,6 +146,10 @@ sub build { > if scalar @{ $fk->{keys} } == 1 > } > >+ if ($source eq 'Branch') { >+ $self->fill_discrete_calendar({ branchcode => $col_values->{branchcode} }); >+ } >+ > # store this record and return hashref > return $self->_storeColumnValues({ > source => $source, >@@ -210,6 +214,32 @@ sub build_sample_item { > )->store->get_from_storage; > } > >+sub fill_discrete_calendar { >+ my ( $self, $args ) = @_; >+ >+ my $branchcode = $args->{branchcode} || ''; >+ my $start_date = ($args->{start_date}) ? dt_from_string($args->{start_date}) : DateTime->today(); >+ my $days = $args->{days} || 60; >+ >+ my $end_date = $start_date->clone(); >+ $start_date->add(days => 0 - $days); >+ $end_date->add(days => $days); >+ >+ for (1; $start_date <= $end_date; $start_date->add(days => 1)) { >+ my $data = { >+ date => output_pref( { dt => $start_date, dateformat => 'iso', dateonly => 1 }), >+ branchcode => $branchcode, >+ is_opened => 1, >+ open_hour => "08:00:00", >+ close_hour => "17:00:00", >+ }; >+ >+ $self->schema->resultset( "DiscreteCalendar" )->update_or_create( $data ); >+ } >+ >+ return >+} >+ > # ------------------------------------------------------------------------------ > # Internal helper routines > >-- >2.34.1
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 17015
:
53859
|
54318
|
54419
|
59166
|
59167
|
59168
|
59169
|
59170
|
59171
|
59267
|
59268
|
59269
|
59270
|
59271
|
59463
|
59516
|
59517
|
59518
|
59519
|
59520
|
59561
|
59562
|
59586
|
59587
|
59888
|
59889
|
60902
|
60903
|
60904
|
60905
|
60906
|
60986
|
61737
|
62375
|
62376
|
62380
|
63257
|
63282
|
63362
|
63363
|
63364
|
63365
|
63366
|
63367
|
64235
|
65073
|
65074
|
65075
|
65076
|
65077
|
67721
|
67722
|
67723
|
67724
|
67725
|
67879
|
67929
|
67930
|
67931
|
67932
|
67933
|
67934
|
68392
|
68393
|
68394
|
68395
|
68396
|
68397
|
71634
|
71635
|
71636
|
71637
|
71638
|
72890
|
73145
|
74859
|
74860
|
74861
|
74862
|
74863
|
74864
|
74865
|
74866
|
75444
|
75479
|
76594
|
77249
|
77250
|
77607
|
77608
|
77609
|
77610
|
77611
|
77612
|
77613
|
77770
|
77771
|
77772
|
77773
|
77774
|
79035
|
80523
|
80524
|
80525
|
80526
|
80527
|
80528
|
80529
|
80530
|
80531
|
80532
|
80533
|
80534
|
80535
|
83547
|
85394
|
85677
|
85678
|
85679
|
85680
|
85681
|
85682
|
85683
|
85684
|
85685
|
85686
|
85687
|
85688
|
85689
|
85690
|
85691
|
92595
|
92596
|
92597
|
92598
|
100079
|
110383
|
110384
|
110386
|
110387
|
110388
|
110389
|
113541
|
113905
|
115501
|
115502
|
115503
|
115504
|
115505
|
115506
|
115507
|
115508
|
115509
|
115510
|
115511
|
118554
|
118555
|
118556
|
118557
|
118558
|
118559
|
119095
|
119097
|
119099
|
119100
|
119101
|
119102
|
131619
|
131620
|
131621
|
131622
|
131623
|
131624
|
131625
|
131626
|
131634
|
131635
|
131636
|
131637
|
131638
|
131639
|
131640
|
131641
|
131667
|
132199
|
133596
|
133597
|
133598
|
133599
|
133600
|
133601
|
133602
|
133603
|
133604
|
133605
|
133678
|
137219
|
137220
|
137221
|
137222
|
137223
|
137224
|
137225
|
137226
|
137227
|
137228
|
137229
|
139378
|
139379
|
139380
|
139381
|
139382
|
139599
|
139600
|
139601
|
139602
|
139603
|
139851
|
140150
|
141176
|
144257
|
144258
|
144259
|
144260
|
144261
|
144262
|
144264
|
144268
|
144269
|
144270
|
144271
|
144272
|
144273
|
151438
|
151439
|
151440
|
151441
|
151442
|
151443
|
151444
|
151445
|
151446
|
151447
|
151448
|
151449
|
151450
|
156340
|
156341
|
156342
|
156343
|
156344
|
156345
|
156346
|
156347
|
156348
|
156349
|
156350
|
156351
|
156352
|
156353
|
156354
|
156355
|
157656
|
157657
|
157658
|
157659
|
157660
|
157661
|
157662
|
157663
|
157664
|
157665
|
157666
|
157667
|
157668
|
157669
|
157670
|
157671
|
157672
|
167805
|
167806
|
167807
|
167808
|
167809