From 780dfa534951f2e5124457cbe99c977843e13a18 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 18 Jun 2013 08:37:09 -0700 Subject: [PATCH] Bug 10332: further improvements to course reserves tests - Wrap tests in a database transaction; that way, no special cleanup code is required - Use AddItem rather than AddItemFromMarc to create test items; there's no need to build in a dependence on any particular MARC flavor or framework in our test cases (except, of course, for test cases that are explicitly exercising code that involves the frameworks). Signed-off-by: Galen Charlton --- t/db_dependent/CourseReserves.t | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t index d122005..ddb6ad9 100755 --- a/t/db_dependent/CourseReserves.t +++ b/t/db_dependent/CourseReserves.t @@ -11,13 +11,17 @@ BEGIN { use_ok('C4::Biblio'); use_ok('C4::Context'); use_ok('C4::CourseReserves', qw/:all/); - use_ok('C4::Items', qw(AddItemFromMarc)); + use_ok('C4::Items', qw(AddItem)); use_ok('MARC::Field'); use_ok('MARC::Record'); } my $dbh = C4::Context->dbh; +# Start transaction +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10"); $sth->execute(); my @borrowers = @{ $sth->fetchall_arrayref( {} ) }; @@ -28,7 +32,7 @@ $record->append_fields( MARC::Field->new( '952', '0', '0', a => 'CPL', b => 'CPL' ) ); my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); -my @iteminfo = C4::Items::AddItemFromMarc( $record, $biblionumber ); +my @iteminfo = C4::Items::AddItem( { homebranch => 'CPL', holdingbranch => 'CPL' }, $biblionumber ); my $itemnumber = $iteminfo[2]; my $course_id = ModCourse( @@ -87,7 +91,4 @@ DelCourse($course_id); $course = GetCourse($course_id); ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" ); -END { - C4::Items::DelItem( $dbh, $biblionumber, $itemnumber ); - C4::Biblio::DelBiblio( $biblionumber ); -}; +$dbh->rollback; -- 1.7.2.5