Bugzilla – Attachment 59918 Details for
Bug 17950
Small improvements for Merge.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17950: Merge.t: Improve variable handling at top level
Bug-17950-Merget-Improve-variable-handling-at-top-.patch (text/plain), 3.52 KB, created by
Julian Maurice
on 2017-02-06 08:37:05 UTC
(
hide
)
Description:
Bug 17950: Merge.t: Improve variable handling at top level
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-02-06 08:37:05 UTC
Size:
3.52 KB
patch
obsolete
>From c49be33ca91298f343f9c7578d9b6774b9540320 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 23 Jan 2017 11:40:48 +0100 >Subject: [PATCH] Bug 17950: Merge.t: Improve variable handling at top level > >This patch does: >[1] Remove unused $dbh. >[2] Move all mocking statements to one sub. >[3] Promote a few lexicals to globals when used in the subtests. > >Test plan: >Run t/db_dependent/Authorities/Merge.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > t/db_dependent/Authorities/Merge.t | 47 +++++++++++++++++++------------------- > 1 file changed, 24 insertions(+), 23 deletions(-) > >diff --git a/t/db_dependent/Authorities/Merge.t b/t/db_dependent/Authorities/Merge.t >index 628dff0d0f..726bad629d 100755 >--- a/t/db_dependent/Authorities/Merge.t >+++ b/t/db_dependent/Authorities/Merge.t >@@ -28,20 +28,11 @@ t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ) if $marcflavour; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >-my $dbh = C4::Context->dbh; > >-# Some advanced mocking :) >-my ( @zebrarecords, $index ); >-my $context_mod = Test::MockModule->new( 'C4::Context' ); >-my $search_mod = Test::MockModule->new( 'C4::Search' ); >-my $zoom_mod = Test::MockModule->new( 'ZOOM::Query::CCL2RPN', no_auto => 1 ); >-my $conn_obj = Test::MockObject->new; >-my $zoom_obj = Test::MockObject->new; >-my $zoom_record_obj = Test::MockObject->new; >-set_mocks(); >- >-# Framework operations >-my ( $authtype1, $authtype2 ) = modify_framework(); >+# Global variables, mocking and framework modifications >+our ( @zebrarecords, $index ); >+my $mocks = set_mocks(); >+our ( $authtype1, $authtype2 ) = modify_framework(); > > subtest 'Test merge A1 to A2 (within same authtype)' => sub { > # Tests originate from bug 11700 >@@ -229,19 +220,29 @@ sub set_mocks { > # Mock ZOOM objects: They do nothing actually > # Get new_record_from_zebra to return the records > >- $context_mod->mock( 'Zconn', sub { $conn_obj; } ); >- $search_mod->mock( 'new_record_from_zebra', sub { >+ my $mocks; >+ $mocks->{context_mod} = Test::MockModule->new( 'C4::Context' ); >+ $mocks->{search_mod} = Test::MockModule->new( 'C4::Search' ); >+ $mocks->{zoom_mod} = Test::MockModule->new( 'ZOOM::Query::CCL2RPN', no_auto => 1 ); >+ $mocks->{conn_obj} = Test::MockObject->new; >+ $mocks->{zoom_obj} = Test::MockObject->new; >+ $mocks->{zoom_record_obj} = Test::MockObject->new; >+ >+ $mocks->{context_mod}->mock( 'Zconn', sub { $mocks->{conn_obj}; } ); >+ $mocks->{search_mod}->mock( 'new_record_from_zebra', sub { > return if $index >= @zebrarecords; > return $zebrarecords[ $index++ ]; > }); >- $zoom_mod->mock( 'new', sub {} ); >- >- $conn_obj->mock( 'search', sub { $zoom_obj; } ); >- $zoom_obj->mock( 'destroy', sub {} ); >- $zoom_obj->mock( 'record', sub { $zoom_record_obj; } ); >- $zoom_obj->mock( 'search', sub {} ); >- $zoom_obj->mock( 'size', sub { @zebrarecords } ); >- $zoom_record_obj->mock( 'raw', sub {} ); >+ $mocks->{zoom_mod}->mock( 'new', sub {} ); >+ >+ $mocks->{conn_obj}->mock( 'search', sub { $mocks->{zoom_obj}; } ); >+ $mocks->{zoom_obj}->mock( 'destroy', sub {} ); >+ $mocks->{zoom_obj}->mock( 'record', sub { $mocks->{zoom_record_obj}; } ); >+ $mocks->{zoom_obj}->mock( 'search', sub {} ); >+ $mocks->{zoom_obj}->mock( 'size', sub { @zebrarecords } ); >+ $mocks->{zoom_record_obj}->mock( 'raw', sub {} ); >+ >+ return $mocks; > } > > sub modify_framework { >-- >2.11.0
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 17950
:
59397
|
59398
|
59399
|
59689
|
59690
|
59917
| 59918