Bugzilla – Attachment 43865 Details for
Bug 14778
DBIC should create/own the DB handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 14778: Install fixtures for t/Calendar.t
PASSED-QA-Bug-14778-Install-fixtures-for-tCalendar.patch (text/plain), 5.78 KB, created by
Kyle M Hall (khall)
on 2015-10-23 14:56:36 UTC
(
hide
)
Description:
[PASSED QA] Bug 14778: Install fixtures for t/Calendar.t
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-10-23 14:56:36 UTC
Size:
5.78 KB
patch
obsolete
>From c68acdfe3bc5e4b417f757dac4102029f86dbff7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 15 Oct 2015 16:44:32 +0100 >Subject: [PATCH] [PASSED QA] Bug 14778: Install fixtures for t/Calendar.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/Calendar.t | 115 ++++++++++++++++++++-------------------------------------- > 1 files changed, 39 insertions(+), 76 deletions(-) > >diff --git a/t/Calendar.t b/t/Calendar.t >index 758f60b..7fabe3a 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -1,12 +1,10 @@ > #!/usr/bin/env perl > >-use strict; >-use warnings; >+use Modern::Perl; > use DateTime; > use DateTime::Duration; >-use Test::More tests => 34; >+use Test::More tests => 35; > use Test::MockModule; >-use DBD::Mock; > use Koha::Cache; > use Koha::DateUtils; > >@@ -17,20 +15,32 @@ BEGIN { > # Remove when no longer used > #use_ok('C4::Calendar'); # not used anymore? > } >+use Test::DBIx::Class { >+ schema_class => 'Koha::Schema', >+ connect_info => ['dbi:SQLite:dbname=:memory:','',''], >+ connect_opts => { name_sep => '.', quote_char => '`', }, >+ fixture_class => '::Populate', >+}, 'Biblio' ; >+ >+sub fixtures { >+ my ( $data ) = @_; >+ fixtures_ok [ >+ Biblio => [ >+ [ qw/ biblionumber datecreated timestamp / ], >+ @$data, >+ ], >+ ], 'add fixtures'; >+} > >-my $module_context = new Test::MockModule('C4::Context'); >-$module_context->mock( >- '_new_dbh', >- sub { >- my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) >- || die "Cannot create handle: $DBI::errstr\n"; >- return $dbh; >- } >+my $db = Test::MockModule->new('Koha::Database'); >+$db->mock( >+ _new_schema => sub { return Schema(); } > ); > > # We need to mock the C4::Context->preference method for > # simplicity and re-usability of the session definition. Any > # syspref fits for syspref-agnostic tests. >+my $module_context = new Test::MockModule('C4::Context'); > $module_context->mock( > 'preference', > sub { >@@ -38,70 +48,32 @@ $module_context->mock( > } > ); > >-SKIP: { >- >-skip "DBD::Mock is too old", 33 >- unless $DBD::Mock::VERSION >= 1.45; >- >-my $holidays_session = DBD::Mock::Session->new('holidays_session' => ( >- { # weekly holidays >- statement => "SELECT weekday FROM repeatable_holidays WHERE branchcode = ? AND weekday IS NOT NULL", >- results => [ >- ['weekday'], >- [0], # sundays >- [6] # saturdays >- ] >- }, >- { # day and month repeatable holidays >- statement => "SELECT day, month FROM repeatable_holidays WHERE branchcode = ? AND weekday IS NULL", >- results => [ >- [ 'month', 'day' ], >- [ 1, 1 ], # new year's day >- [12,25] # christmas >- ] >- }, >- { # exception holidays >- statement => "SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 1", >- results => [ >- [ 'day', 'month', 'year' ], >- [ 11, 11, 2012 ] # sunday exception >- ] >- }, >- >- { # single holidays1 >- statement => "SELECT distinct(branchcode) FROM special_holidays", >- results => [ >- [ 'branchcode' ], >- [ 'MPL'] >- ] >- }, >- >- { # single holidays2 >- statement => "SELECT day, month, year FROM special_holidays WHERE branchcode = ? AND isexception = 0", >- results => [ >- [ 'day', 'month', 'year' ], >- [ 1, 6, 2011 ], # single holiday >- [ 4, 7, 2012 ] >- ] >- }, >-)); >- >-# Initialize the global $dbh variable >-my $dbh = C4::Context->dbh(); >-# Apply the mock session >-$dbh->{ mock_session } = $holidays_session; >- >+fixtures_ok [ >+ # weekly holidays >+ RepeatableHoliday => [ >+ [ qw( branchcode day month weekday title description) ], >+ [ 'MPL', undef, undef, 0, '', '' ], # sundays >+ [ 'MPL', undef, undef, 6, '', '' ],# saturdays >+ [ 'MPL', 1, 1, undef, '', ''], # new year's day >+ [ 'MPL', 25, 12, undef, '', ''], # chrismas >+ ], >+ # exception holidays >+ SpecialHoliday => [ >+ [qw( branchcode day month year title description isexception )], >+ [ 'MPL', 11, 11, 2012, '', '', 1 ], # sunday exception >+ [ 'MPL', 1, 6, 2011, '', '', 0 ], >+ [ 'MPL', 4, 7, 2012, '', '', 0 ], >+ ], >+], "add fixtures"; > > my $cache = Koha::Cache->get_instance(); > $cache->clear_from_cache( 'single_holidays') ; > >- > # 'MPL' branch is arbitrary, is not used at all but is needed for initialization > my $cal = Koha::Calendar->new( branchcode => 'MPL' ); > > isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' ); > >- > my $saturday = DateTime->new( > year => 2012, > month => 11, >@@ -224,9 +196,6 @@ my $day_after_christmas = DateTime->new( > return 'Datedue'; > } > ); >- # rewind dbh session >- $holidays_session->reset; >- > > $cal = Koha::Calendar->new( branchcode => 'MPL' ); > >@@ -266,8 +235,6 @@ my $day_after_christmas = DateTime->new( > return 'Calendar'; > } > ); >- # rewind dbh session >- $holidays_session->reset; > > $cal = Koha::Calendar->new( branchcode => 'MPL' ); > >@@ -303,8 +270,6 @@ my $day_after_christmas = DateTime->new( > return 'Days'; > } > ); >- # rewind dbh session >- $holidays_session->reset; > > $cal = Koha::Calendar->new( branchcode => 'MPL' ); > >@@ -333,5 +298,3 @@ my $day_after_christmas = DateTime->new( > '==', 40, 'Test parameter order not relevant (Days)' ); > > } >- >-} # End SKIP block >-- >1.7.2.5
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 14778
:
42326
|
42388
|
43247
|
43248
|
43249
|
43250
|
43440
|
43631
|
43632
|
43633
|
43634
|
43635
|
43636
|
43637
|
43638
|
43639
|
43640
|
43641
|
43642
|
43643
|
43644
|
43645
|
43834
|
43835
|
43836
|
43837
|
43838
|
43839
|
43840
|
43841
|
43842
|
43843
|
43844
|
43845
|
43846
|
43847
|
43848
|
43849
|
43850
|
43851
|
43852
|
43853
|
43857
|
43858
|
43859
|
43860
|
43861
|
43862
|
43863
|
43864
| 43865 |
43866
|
43867
|
43868
|
43869
|
43870
|
43871
|
43872
|
43873
|
43874
|
43875
|
43876
|
44003