Bug 11439: UT: Improve XISBN.t
The tests should be executed into a transaction and the SimpleSearch routine correctly mocked. Test plan: Verify that prove t/db_dependent/XISBN.t returns green. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
81133cf2c2
commit
0d71139fff
1 changed files with 8 additions and 10 deletions
|
@ -5,21 +5,24 @@
|
||||||
|
|
||||||
use Modern::Perl;
|
use Modern::Perl;
|
||||||
|
|
||||||
# use Test::Class::Load qw ( t/db_dependent/ );
|
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 5;
|
||||||
use MARC::Record;
|
use MARC::Record;
|
||||||
use C4::Biblio;
|
use C4::Biblio;
|
||||||
use C4::XISBN;
|
use C4::XISBN;
|
||||||
use Data::Dumper;
|
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
|
use Test::MockModule;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use_ok('C4::XISBN');
|
use_ok('C4::XISBN');
|
||||||
}
|
}
|
||||||
|
|
||||||
# Avoid "redefined subroutine" warnings
|
my $dbh = C4::Context->dbh;
|
||||||
local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ };
|
$dbh->{RaiseError} = 1;
|
||||||
*C4::Search::SimpleSearch = \&Mock_SimpleSearch;
|
$dbh->{AutoCommit} = 0;
|
||||||
|
|
||||||
|
my $search_module = new Test::MockModule('C4::Search');
|
||||||
|
|
||||||
|
$search_module->mock('SimpleSearch', \&Mock_SimpleSearch );
|
||||||
|
|
||||||
my $context = C4::Context->new;
|
my $context = C4::Context->new;
|
||||||
|
|
||||||
|
@ -62,11 +65,6 @@ is( $results_xisbn->[0]->{biblionumber},
|
||||||
$biblionumber3,
|
$biblionumber3,
|
||||||
"Gets correct biblionumber from a book with a similar isbn using XISBN." );
|
"Gets correct biblionumber from a book with a similar isbn using XISBN." );
|
||||||
|
|
||||||
# clean up after ourselves
|
|
||||||
DelBiblio($biblionumber1);
|
|
||||||
DelBiblio($biblionumber2);
|
|
||||||
DelBiblio($biblionumber3);
|
|
||||||
|
|
||||||
# Util subs
|
# Util subs
|
||||||
|
|
||||||
# Add new biblio with isbn and return biblionumber
|
# Add new biblio with isbn and return biblionumber
|
||||||
|
|
Loading…
Reference in a new issue