Bugzilla – Attachment 155104 Details for
Bug 33869
Move Matcher.t to db_dependent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33869: Matcher.t - use TestBuilder
Bug-33869-Matchert---use-TestBuilder.patch (text/plain), 3.19 KB, created by
Jonathan Druart
on 2023-09-01 12:01:58 UTC
(
hide
)
Description:
Bug 33869: Matcher.t - use TestBuilder
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-09-01 12:01:58 UTC
Size:
3.19 KB
patch
obsolete
>From c0df2b6330afad46ce3a80e801c175c7195a55ba Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 29 May 2023 07:08:19 +0000 >Subject: [PATCH] Bug 33869: Matcher.t - use TestBuilder > >Remove T::D::C > >Test plan: >Run t/Matcher.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/Matcher.t | 52 ++++++++++++++++++++++++---------------------------- > 1 file changed, 24 insertions(+), 28 deletions(-) > >diff --git a/t/Matcher.t b/t/Matcher.t >index 2c7b2887698..bc5ccb76591 100755 >--- a/t/Matcher.t >+++ b/t/Matcher.t >@@ -16,47 +16,40 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- >-use Test::More; >-use Test::MockModule; >-use Test::Warn; >- > use MARC::Record; >+use Test::More tests => 3; >+use Test::Warn; > >-use Module::Load::Conditional qw/check_install/; >- >-BEGIN { >- if ( check_install( module => 'Test::DBIx::Class' ) ) { >- plan tests => 13; >- } else { >- plan skip_all => "Need Test::DBIx::Class" >- } >-} >+use t::lib::TestBuilder; >+use t::lib::Mocks; > >-use Test::DBIx::Class; >+use Koha::Database; >+use C4::Matcher qw( GetMatcherList GetMatcherId ); > >-my $db = Test::MockModule->new('Koha::Database'); >-$db->mock( _new_schema => sub { return Schema(); } ); >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+$schema->storage->txn_begin; > >-use_ok('C4::Matcher', qw( GetMatcherList GetMatcherId )); >+subtest 'GetMatcherList' => sub { >+ plan tests => 9; > >-fixtures_ok [ >- MarcMatcher => [ >- [ 'matcher_id', 'code', 'description', 'record_type', 'threshold' ], >- [ 1, 'ISBN', 'ISBN', 'red', 1 ], >- [ 2, 'ISSN', 'ISSN', 'blue', 0 ] >- ], >-], 'add fixtures'; >+ $schema->resultset('MarcMatcher')->delete_all; >+ my $matcher1 = $builder->build({ source => 'MarcMatcher', >+ value => { code => 'ISBN', description => 'ISBN', record_type => 'red', threshold => 1 }, >+ }); >+ my $matcher2 = $builder->build({ source => 'MarcMatcher', >+ value => { code => 'ISSN', description => 'ISSN', record_type => 'blue', threshold => 0 }, >+ }); > > my @matchers = C4::Matcher::GetMatcherList(); > >-is( $matchers[0]->{'matcher_id'}, 1, 'First matcher_id value is 1' ); >+is( $matchers[0]->{'matcher_id'}, $matcher1->{matcher_id}, 'First matcher_id value' ); > >-is( $matchers[1]->{'matcher_id'}, 2, 'Second matcher_id value is 2' ); >+is( $matchers[1]->{'matcher_id'}, $matcher2->{matcher_id}, 'Second matcher_id value' ); > > my $matcher_id = C4::Matcher::GetMatcherId('ISBN'); > >-is( $matcher_id, 1, 'testing getmatcherid' ); >+is( $matcher_id, $matcher1->{matcher_id}, 'testing getmatcherid' ); > > my $testmatcher; > >@@ -79,6 +72,7 @@ is( $testmatcher->code(), 'match on ISBN', 'testing code accessor' ); > $testmatcher->description('match on ISSN'); > > is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' ); >+}; > > subtest '_get_match_keys() tests' => sub { > >@@ -402,3 +396,5 @@ sub get_leader_matchpoint { > > return $matchpoint; > } >+ >+$schema->storage->txn_rollback; >-- >2.25.1
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 33869
:
151872
|
151873
|
151874
|
153438
|
153439
|
153440
| 155104 |
155105
|
155106