View | Details | Raw Unified | Return to bug 33869
Collapse All | Expand All

(-)a/t/Matcher.t (-29 / +24 lines)
Lines 16-62 Link Here
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
20
use Test::More;
21
use Test::MockModule;
22
use Test::Warn;
23
24
use MARC::Record;
19
use MARC::Record;
20
use Test::More tests => 3;
21
use Test::Warn;
25
22
26
use Module::Load::Conditional qw/check_install/;
23
use t::lib::TestBuilder;
27
24
use t::lib::Mocks;
28
BEGIN {
29
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
30
        plan tests => 13;
31
    } else {
32
        plan skip_all => "Need Test::DBIx::Class"
33
    }
34
}
35
25
36
use Test::DBIx::Class;
26
use Koha::Database;
27
use C4::Matcher qw( GetMatcherList GetMatcherId );
37
28
38
my $db = Test::MockModule->new('Koha::Database');
29
my $schema  = Koha::Database->new->schema;
39
$db->mock( _new_schema => sub { return Schema(); } );
30
my $builder = t::lib::TestBuilder->new;
31
$schema->storage->txn_begin;
40
32
41
use_ok('C4::Matcher', qw( GetMatcherList GetMatcherId ));
33
subtest 'GetMatcherList' => sub {
34
    plan tests => 9;
42
35
43
fixtures_ok [
36
    $schema->resultset('MarcMatcher')->delete_all;
44
    MarcMatcher => [
37
    my $matcher1 = $builder->build({ source => 'MarcMatcher',
45
        [ 'matcher_id', 'code', 'description', 'record_type', 'threshold' ],
38
        value => { code => 'ISBN', description => 'ISBN', record_type => 'red', threshold => 1 },
46
        [ 1,            'ISBN', 'ISBN',        'red',         1 ],
39
    });
47
        [ 2,            'ISSN', 'ISSN',        'blue',        0 ]
40
    my $matcher2 = $builder->build({ source => 'MarcMatcher',
48
    ],
41
        value => { code => 'ISSN', description => 'ISSN', record_type => 'blue', threshold => 0 },
49
], 'add fixtures';
42
    });
50
43
51
my @matchers = C4::Matcher::GetMatcherList();
44
my @matchers = C4::Matcher::GetMatcherList();
52
45
53
is( $matchers[0]->{'matcher_id'}, 1, 'First matcher_id value is 1' );
46
is( $matchers[0]->{'matcher_id'}, $matcher1->{matcher_id}, 'First matcher_id value' );
54
47
55
is( $matchers[1]->{'matcher_id'}, 2, 'Second matcher_id value is 2' );
48
is( $matchers[1]->{'matcher_id'}, $matcher2->{matcher_id}, 'Second matcher_id value' );
56
49
57
my $matcher_id = C4::Matcher::GetMatcherId('ISBN');
50
my $matcher_id = C4::Matcher::GetMatcherId('ISBN');
58
51
59
is( $matcher_id, 1, 'testing getmatcherid' );
52
is( $matcher_id, $matcher1->{matcher_id}, 'testing getmatcherid' );
60
53
61
my $testmatcher;
54
my $testmatcher;
62
55
Lines 79-84 is( $testmatcher->code(), 'match on ISBN', 'testing code accessor' ); Link Here
79
$testmatcher->description('match on ISSN');
72
$testmatcher->description('match on ISSN');
80
73
81
is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' );
74
is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' );
75
};
82
76
83
subtest '_get_match_keys() tests' => sub {
77
subtest '_get_match_keys() tests' => sub {
84
78
Lines 402-404 sub get_leader_matchpoint { Link Here
402
396
403
    return $matchpoint;
397
    return $matchpoint;
404
}
398
}
405
- 
399
400
$schema->storage->txn_rollback;

Return to bug 33869