Browse Source

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 <gmc@esilibrary.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
new/bootstrap-opac
Galen Charlton 9 years ago
parent
commit
8743f5aab5
  1. 13
      t/db_dependent/CourseReserves.t

13
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;

Loading…
Cancel
Save