Bugzilla – Attachment 43638 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]
Bug 14778: Install fixtures for t/Koha.t
Bug-14778-Install-fixtures-for-tKohat.patch (text/plain), 3.14 KB, created by
Jonathan Druart
on 2015-10-20 15:02:14 UTC
(
hide
)
Description:
Bug 14778: Install fixtures for t/Koha.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-20 15:02:14 UTC
Size:
3.14 KB
patch
obsolete
>From 6f42b41dde61a4cb9896181b1af943a6a9ad0eed Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 20 Oct 2015 13:02:15 +0100 >Subject: [PATCH] Bug 14778: Install fixtures for t/Koha.t > >Warning: This patch modifies a module! >What's the need of the binary function here? >The data are case insensitive, so no need to use this mysql function. >--- > C4/Koha.pm | 2 +- > t/Koha.t | 61 ++++++++++++++++++++++++++++++------------------------------- > 2 files changed, 31 insertions(+), 32 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index bca12d6..4f68ae7 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1237,7 +1237,7 @@ sub IsAuthorisedValueCategory { > my $query = ' > SELECT category > FROM authorised_values >- WHERE BINARY category=? >+ WHERE category=? > LIMIT 1 > '; > my $sth = C4::Context->dbh->prepare($query); >diff --git a/t/Koha.t b/t/Koha.t >index 933fd5b..e4d46f2 100755 >--- a/t/Koha.t >+++ b/t/Koha.t >@@ -18,41 +18,40 @@ > use Modern::Perl; > > use C4::Context; >-use Test::More tests => 29; >+use Test::More tests => 30; > use Test::MockModule; >-use DBD::Mock; > > use_ok('C4::Koha'); > >-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; >- } >-); >- >-SKIP: { >- >- skip "DBD::Mock is too old", 3 >- unless $DBD::Mock::VERSION >= 1.45; >- >- my @loc_results = (['category'],['LOC']); >- my @empty_results = ([]); >- my @relterms_results = (['category'],['RELTERMS']); >- >- my $dbh = C4::Context->dbh(); >- >- $dbh->{mock_add_resultset} = \@loc_results; >- is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category'); >- $dbh->{mock_add_resultset} = \@empty_results; >- is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category'); >- $dbh->{mock_add_resultset} = \@relterms_results; >- is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category'); >- >-} # End SKIP block >+use Test::DBIx::Class { >+ schema_class => 'Koha::Schema', >+ connect_info => ['dbi:SQLite:dbname=:memory:','',''], >+ connect_opts => { name_sep => '.', quote_char => '`', }, >+ fixture_class => '::Populate', >+}, 'AuthorisedValue' ; >+ >+sub fixtures { >+ my ( $data ) = @_; >+ fixtures_ok [ >+ AuthorisedValue => [ >+ [ 'category', 'authorised_value' ], >+ @$data, >+ ], >+ ], 'add fixtures'; >+} >+ >+my $db = Test::MockModule->new('Koha::Database'); >+$db->mock( _new_schema => sub { return Schema(); } ); >+ >+my $authorised_values = [ >+ ['LOC', 'LOC'], >+ ['RELTERMS', 'RELTERMS'], >+]; >+fixtures($authorised_values); >+ >+is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category'); >+is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category'); >+is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category'); > > # > # test that &slashifyDate returns correct (non-US) date >-- >2.1.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 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