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. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
2350a19d43
commit
cc73c53c6f
2 changed files with 27 additions and 28 deletions
|
@ -1291,7 +1291,7 @@ sub IsAuthorisedValueCategory {
|
||||||
my $query = '
|
my $query = '
|
||||||
SELECT category
|
SELECT category
|
||||||
FROM authorised_values
|
FROM authorised_values
|
||||||
WHERE BINARY category=?
|
WHERE category=?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
';
|
';
|
||||||
my $sth = C4::Context->dbh->prepare($query);
|
my $sth = C4::Context->dbh->prepare($query);
|
||||||
|
|
53
t/Koha.t
53
t/Koha.t
|
@ -18,41 +18,40 @@
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use Test::More tests => 29;
|
use Test::More tests => 30;
|
||||||
use Test::MockModule;
|
use Test::MockModule;
|
||||||
use DBD::Mock;
|
|
||||||
|
|
||||||
use_ok('C4::Koha');
|
use_ok('C4::Koha');
|
||||||
|
|
||||||
my $module_context = new Test::MockModule('C4::Context');
|
use Test::DBIx::Class {
|
||||||
$module_context->mock(
|
schema_class => 'Koha::Schema',
|
||||||
'_new_dbh',
|
connect_info => ['dbi:SQLite:dbname=:memory:','',''],
|
||||||
sub {
|
connect_opts => { name_sep => '.', quote_char => '`', },
|
||||||
my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
|
fixture_class => '::Populate',
|
||||||
|| die "Cannot create handle: $DBI::errstr\n";
|
}, 'AuthorisedValue' ;
|
||||||
return $dbh;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
SKIP: {
|
sub fixtures {
|
||||||
|
my ( $data ) = @_;
|
||||||
|
fixtures_ok [
|
||||||
|
AuthorisedValue => [
|
||||||
|
[ 'category', 'authorised_value' ],
|
||||||
|
@$data,
|
||||||
|
],
|
||||||
|
], 'add fixtures';
|
||||||
|
}
|
||||||
|
|
||||||
skip "DBD::Mock is too old", 3
|
my $db = Test::MockModule->new('Koha::Database');
|
||||||
unless $DBD::Mock::VERSION >= 1.45;
|
$db->mock( _new_schema => sub { return Schema(); } );
|
||||||
|
|
||||||
my @loc_results = (['category'],['LOC']);
|
my $authorised_values = [
|
||||||
my @empty_results = ([]);
|
['LOC', 'LOC'],
|
||||||
my @relterms_results = (['category'],['RELTERMS']);
|
['RELTERMS', 'RELTERMS'],
|
||||||
|
];
|
||||||
|
fixtures($authorised_values);
|
||||||
|
|
||||||
my $dbh = C4::Context->dbh();
|
is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
|
||||||
|
is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
|
||||||
$dbh->{mock_add_resultset} = \@loc_results;
|
is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
|
||||||
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
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# test that &slashifyDate returns correct (non-US) date
|
# test that &slashifyDate returns correct (non-US) date
|
||||||
|
|
Loading…
Reference in a new issue