Browse Source
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>3.10.x
Bart Jorgensen
12 years ago
committed by
Paul Poulain
1 changed files with 55 additions and 5 deletions
@ -1,14 +1,64 @@ |
|||
#!/usr/bin/perl |
|||
# |
|||
# This Koha test module is a stub! |
|||
# Add more tests here!!! |
|||
#testing C4 matcher |
|||
|
|||
use strict; |
|||
use warnings; |
|||
|
|||
use Test::More tests => 1; |
|||
use Test::More tests => 10; |
|||
use Test::MockModule; |
|||
|
|||
BEGIN { |
|||
use_ok('C4::Matcher'); |
|||
use_ok('C4::Matcher'); |
|||
} |
|||
|
|||
my $module = new Test::MockModule('C4::Context'); |
|||
$module->mock( |
|||
'_new_dbh', |
|||
sub { |
|||
my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) |
|||
|| die "Cannot create handle: $DBI::errstr\n"; |
|||
return $dbh; |
|||
} |
|||
); |
|||
my $matcher = [ |
|||
[ 'matcher_id', 'code', 'description', 'record_type', 'threshold' ], |
|||
[ 1, 'ISBN', 'ISBN', 'red', 1 ], |
|||
[ 2, 'ISSN', 'ISSN', 'blue', 0 ] |
|||
]; |
|||
my $dbh = C4::Context->dbh(); |
|||
|
|||
$dbh->{mock_add_resultset} = $matcher; |
|||
|
|||
my @matchers = C4::Matcher::GetMatcherList(); |
|||
|
|||
is( $matchers[0]->{'matcher_id'}, 1, 'First matcher_id value is 1' ); |
|||
|
|||
is( $matchers[1]->{'matcher_id'}, 2, 'Second matcher_id value is 2' ); |
|||
|
|||
$dbh->{mock_add_resultset} = $matcher; |
|||
|
|||
my $matcher_id = C4::Matcher::GetMatcherId('ISBN'); |
|||
|
|||
is( $matcher_id, 1, 'testing getmatcherid' ); |
|||
|
|||
my $testmatcher; |
|||
|
|||
ok( $testmatcher = C4::Matcher->new( 'red', 1 ), 'testing matcher new' ); |
|||
|
|||
ok( $testmatcher = C4::Matcher->new( 'blue', 0 ), 'testing matcher new' ); |
|||
|
|||
$testmatcher->threshold(1000); |
|||
|
|||
is( $testmatcher->threshold(), 1000, 'testing threshhold accessor method' ); |
|||
|
|||
$testmatcher->_id(53); |
|||
|
|||
is( $testmatcher->_id(), 53, 'testing _id accessor' ); |
|||
|
|||
$testmatcher->code('match on ISBN'); |
|||
|
|||
is( $testmatcher->code(), 'match on ISBN', 'testing code accessor' ); |
|||
|
|||
$testmatcher->description('match on ISSN'); |
|||
|
|||
is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' ); |
|||
|
Loading…
Reference in new issue