3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Module
::Load
::Conditional qw
/check_install/;
26 if ( check_install
( module
=> 'Test::DBIx::Class' ) ) {
29 plan skip_all
=> "Need Test::DBIx::Class"
33 use_ok
('C4::Matcher');
35 use Test
::DBIx
::Class
{
36 schema_class
=> 'Koha::Schema',
37 connect_info
=> ['dbi:SQLite:dbname=:memory:','',''],
38 connect_opts
=> { name_sep
=> '.', quote_char
=> '`', },
39 fixture_class
=> '::Populate',
44 [ 'matcher_id', 'code', 'description', 'record_type', 'threshold' ],
45 [ 1, 'ISBN', 'ISBN', 'red', 1 ],
46 [ 2, 'ISSN', 'ISSN', 'blue', 0 ]
50 my $db = Test
::MockModule
->new('Koha::Database');
51 $db->mock( _new_schema
=> sub { return Schema
(); } );
53 my @matchers = C4
::Matcher
::GetMatcherList
();
55 is
( $matchers[0]->{'matcher_id'}, 1, 'First matcher_id value is 1' );
57 is
( $matchers[1]->{'matcher_id'}, 2, 'Second matcher_id value is 2' );
59 my $matcher_id = C4
::Matcher
::GetMatcherId
('ISBN');
61 is
( $matcher_id, 1, 'testing getmatcherid' );
65 ok
( $testmatcher = C4
::Matcher
->new( 'red', 1 ), 'testing matcher new' );
67 ok
( $testmatcher = C4
::Matcher
->new( 'blue', 0 ), 'testing matcher new' );
69 $testmatcher->threshold(1000);
71 is
( $testmatcher->threshold(), 1000, 'testing threshhold accessor method' );
73 $testmatcher->_id(53);
75 is
( $testmatcher->_id(), 53, 'testing _id accessor' );
77 $testmatcher->code('match on ISBN');
79 is
( $testmatcher->code(), 'match on ISBN', 'testing code accessor' );
81 $testmatcher->description('match on ISSN');
83 is
( $testmatcher->description(), 'match on ISSN', 'testing code accessor' );