Bugzilla – Attachment 92521 Details for
Bug 23079
Checkouts page broken because of problems with date calculation (TZAmerica/Sao_Paulo)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23079: Add tests
Bug-23079-Add-tests.patch (text/plain), 4.13 KB, created by
Jonathan Druart
on 2019-09-01 20:03:00 UTC
(
hide
)
Description:
Bug 23079: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-09-01 20:03:00 UTC
Size:
4.13 KB
patch
obsolete
>From 0055d8055d674992585d9ccf4a9e2fe703c10edc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 22 Jun 2019 20:33:45 -0500 >Subject: [PATCH] Bug 23079: Add tests > >--- > t/db_dependent/Koha/Patrons.t | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index e528a59bbd..c8d01188ac 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -303,40 +303,55 @@ subtest 'is_expired' => sub { > }; > > subtest 'is_going_to_expire' => sub { >- plan tests => 8; >+ plan tests => 9; >+ >+ my $today = dt_from_string(undef, undef, 'floating'); > my $patron = $builder->build({ source => 'Borrower' }); > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > $patron->dateexpiry( undef )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is not set'); > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); >- $patron->dateexpiry( dt_from_string )->store->discard_changes; >+ $patron->dateexpiry( $today )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is today'); > >- $patron->dateexpiry( dt_from_string )->store->discard_changes; >+ $patron->dateexpiry( $today )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is today and pref is 0'); > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); >- $patron->dateexpiry( dt_from_string->add( days => 11 ) )->store->discard_changes; >+ $patron->dateexpiry( $today->clone->add( days => 11 ) )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 11 days ahead and pref is 10'); > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); >- $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; >+ $patron->dateexpiry( $today->clone->add( days => 10 ) )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 0'); > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); >- $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; >+ $patron->dateexpiry( $today->clone->add( days => 10 ) )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 10'); > $patron->delete; > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); >- $patron->dateexpiry( dt_from_string->add( days => 20 ) )->store->discard_changes; >+ $patron->dateexpiry( $today->clone->add( days => 20 ) )->store->discard_changes; > is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 20 days ahead and pref is 10'); > > t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 20); >- $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; >+ $patron->dateexpiry( $today->clone->add( days => 10 ) )->store->discard_changes; > is( $patron->is_going_to_expire, 1, 'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 20'); > >+ { # Testing invalid is going to expiry date >+ t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 30); >+ # mock_config does not work here, because of tz vs timezone subroutines >+ my $context = new Test::MockModule('C4::Context'); >+ $context->mock( 'tz', sub { >+ 'America/Sao_Paulo'; >+ }); >+ $patron->dateexpiry(DateTime->new( year => 2019, month => 12, day => 3 ))->store; >+ eval { $patron->is_going_to_expire }; >+ is( $@, '', 'On invalid "is going to expire" date, the method should not crash with "Invalid local time for date in time zone"'); >+ $context->unmock('tz'); >+ }; >+ > $patron->delete; > }; > >-- >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 23079
:
90939
|
90940
|
92521
|
92525
|
92526
|
92552
|
92553