Bugzilla – Attachment 51638 Details for
Bug 15333
Use Koha::Cache for caching all holidays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15333: [QA Follow-up] Add few tests
Bug-15333-QA-Follow-up-Add-few-tests.patch (text/plain), 3.76 KB, created by
Marcel de Rooy
on 2016-05-20 08:33:25 UTC
(
hide
)
Description:
Bug 15333: [QA Follow-up] Add few tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-05-20 08:33:25 UTC
Size:
3.76 KB
patch
obsolete
>From 6998b6a69149b17fd8bb6a4b7b498cf93148021d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 20 May 2016 10:14:28 +0200 >Subject: [PATCH] Bug 15333: [QA Follow-up] Add few tests >Content-Type: text/plain; charset=utf-8 > >This report had no test plan and no unit tests. >Adding some lines to Holidays.t. >Added a trivial line move in Calendar.pm. > >Test plan: >Run t/db_dependent/Holidays.t with and without cache. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Tested with memcached, Cache::Memory and no cache (edit Cache.pm). >--- > Koha/Calendar.pm | 5 +++-- > t/db_dependent/Holidays.t | 49 +++++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 48 insertions(+), 6 deletions(-) > >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index f027ba7..b18f11c 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -54,12 +54,13 @@ sub _init { > > sub exception_holidays { > my ( $self ) = @_; >- my $dbh = C4::Context->dbh; >- my $branch = $self->{branchcode}; >+ > my $cache = Koha::Cache->get_instance(); > my $cached = $cache->get_from_cache('exception_holidays'); > return $cached if $cached; > >+ my $dbh = C4::Context->dbh; >+ my $branch = $self->{branchcode}; > my $exception_holidays_sth = $dbh->prepare( > 'SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1' > ); >diff --git a/t/db_dependent/Holidays.t b/t/db_dependent/Holidays.t >index 3080d5c..07e54cf 100755 >--- a/t/db_dependent/Holidays.t >+++ b/t/db_dependent/Holidays.t >@@ -17,16 +17,16 @@ > > use Modern::Perl; > >-use Test::More tests => 10; >-use t::lib::TestBuilder; >+use Test::More tests => 15; >+use DateTime; >+use DateTime::TimeZone; > >+use t::lib::TestBuilder; > use C4::Context; > use C4::Branch; > use Koha::Database; > use Koha::DateUtils; > >-use DateTime; >-use DateTime::TimeZone; > > BEGIN { > use_ok('Koha::Calendar'); >@@ -119,6 +119,47 @@ C4::Calendar->new( branchcode => $branch_2 )->insert_single_holiday( > is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday( $today ), 1, "Today is a holiday for $branch_2" ); > is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday( $today ), 0, "Today is not a holiday for $branch_1"); > >+# Few tests for exception holidays >+my ( $diff, $cal, $special ); >+$dbh->do("DELETE FROM special_holidays"); >+_add_exception( $today, $branch_1, 'Today' ); >+$cal = Koha::Calendar->new( branchcode => $branch_1 ); >+$special = $cal->exception_holidays; >+is( $special->count, 1, 'One exception holiday added' ); >+ >+my $tomorrow= dt_from_string(); >+$tomorrow->add_duration( DateTime::Duration->new(days => 1) ); >+_add_exception( $tomorrow, $branch_1, 'Tomorrow' ); >+$cal = Koha::Calendar->new( branchcode => $branch_1 ); >+$special = $cal->exception_holidays; >+is( $special->count, 2, 'Set of exception holidays contains two dates' ); >+ >+$diff = $today->delta_days( $special->min )->in_units('days'); >+is( $diff, 0, 'Lowest exception holiday is today' ); >+$diff = $tomorrow->delta_days( $special->max )->in_units('days'); >+is( $diff, 0, 'Highest exception holiday is tomorrow' ); >+ >+C4::Calendar->new( branchcode => $branch_1 )->delete_holiday( >+ weekday => $tomorrow->day_of_week, >+ day => $tomorrow->day, >+ month => $tomorrow->month, >+ year => $tomorrow->year, >+); >+$cal = Koha::Calendar->new( branchcode => $branch_1 ); >+$special = $cal->exception_holidays; >+is( $special->count, 1, 'Set of exception holidays back to one' ); >+ >+sub _add_exception { >+ my ( $dt, $branch, $descr ) = @_; >+ C4::Calendar->new( branchcode => $branch )->insert_exception_holiday( >+ day => $dt->day, >+ month => $dt->month, >+ year => $dt->year, >+ title => $descr, >+ description => $descr, >+ ); >+} >+ > $schema->storage->txn_rollback; > > 1; >-- >1.7.10.4
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 15333
:
51223
|
51637
| 51638