Bugzilla – Attachment 18638 Details for
Bug 10332
UT: CourseReserves.t needs to create its own data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10332: CourseReserves.t needs to create its own data
Bug-10332-CourseReservest-needs-to-create-its-own-.patch (text/plain), 3.97 KB, created by
Jonathan Druart
on 2013-06-04 12:35:19 UTC
(
hide
)
Description:
Bug 10332: CourseReserves.t needs to create its own data
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-06-04 12:35:19 UTC
Size:
3.97 KB
patch
obsolete
>From 7a2f912a5e8791f0b34a6a11c5f02f40350c4cb3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 24 May 2013 14:23:45 +0200 >Subject: [PATCH] Bug 10332: CourseReserves.t needs to create its own data > >prove t/db_dependent/CourseReserves.t >t/db_dependent/CourseReserves.t .. ok >All tests successful. >Files=1, Tests=20, 2 wallclock secs ( 0.02 usr 0.00 sys + 0.43 cusr >0.03 csys = 0.48 CPU) >Result: PASS >--- > t/db_dependent/CourseReserves.t | 40 +++++++++++++++++++++------------------ > 1 file changed, 22 insertions(+), 18 deletions(-) > >diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t >index 9c3172a..a7955e4 100755 >--- a/t/db_dependent/CourseReserves.t >+++ b/t/db_dependent/CourseReserves.t >@@ -3,29 +3,34 @@ > # This is to test C4/Members > # It requires a working Koha database with the sample data > >-use strict; >-use warnings; >+use Modern::Perl; > >-use Test::More tests => 16; >+use Test::More tests => 20; > use Data::Dumper; > > BEGIN { >+ use_ok('C4::Biblio'); > use_ok('C4::Context'); > use_ok('C4::CourseReserves', qw/:all/); >+ use_ok('C4::Items', qw(AddItemFromMarc)); >+ use_ok('MARC::Field'); >+ use_ok('MARC::Record'); > } > > my $dbh = C4::Context->dbh; >-$dbh->do("TRUNCATE TABLE course_instructors"); >-$dbh->do("TRUNCATE TABLE courses"); >-$dbh->do("TRUNCATE TABLE course_reserves"); > > my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10"); > $sth->execute(); > my @borrowers = @{ $sth->fetchall_arrayref( {} ) }; > >-$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10"); >-$sth->execute(); >-my @items = @{ $sth->fetchall_arrayref( {} ) }; >+# Create the item >+my $record = MARC::Record->new(); >+$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 $itemnumber = $iteminfo[2]; > > my $course_id = ModCourse( > course_name => "Test Course", >@@ -55,11 +60,11 @@ ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrow > my $course_instructors = GetCourseInstructors($course_id); > ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); > >-my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} ); >+my $ci_id = ModCourseItem( 'itemnumber' => $itemnumber ); > ok( $ci_id, "ModCourseItem returned valid data" ); > > my $course_item = GetCourseItem( 'ci_id' => $ci_id ); >-ok( $course_item->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetCourseItem returns valid data" ); >+ok( $course_item->{'itemnumber'} eq $itemnumber, "GetCourseItem returns valid data" ); > > my $cr_id = ModCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id ); > ok( $cr_id, "ModCourseReserve returns valid data" ); >@@ -70,8 +75,8 @@ ok( $course_reserve->{'cr_id'} eq $cr_id, "GetCourseReserve returns valid data" > my $course_reserves = GetCourseReserves( 'course_id' => $course_id ); > ok( $course_reserves->[0]->{'ci_id'} eq $ci_id, "GetCourseReserves returns valid data." ); > >-my $info = GetItemCourseReservesInfo( itemnumber => $items[0]->{'itemnumber'} ); >-ok( $info->[0]->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetItemReservesInfo returns valid data." ); >+my $info = GetItemCourseReservesInfo( itemnumber => $itemnumber ); >+ok( $info->[0]->{'itemnumber'} eq $itemnumber, "GetItemReservesInfo returns valid data." ); > > DelCourseReserve( 'cr_id' => $cr_id ); > $course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); >@@ -81,8 +86,7 @@ DelCourse($course_id); > $course = GetCourse($course_id); > ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" ); > >-$dbh->do("TRUNCATE TABLE course_instructors"); >-$dbh->do("TRUNCATE TABLE courses"); >-$dbh->do("TRUNCATE TABLE course_reserves"); >- >-exit; >+END { >+ C4::Items::DelItem( $dbh, $biblionumber, $itemnumber ); >+ C4::Biblio::DelBiblio( $biblionumber ); >+}; >-- >1.7.10.4
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 10332
:
18382
|
18638
|
18645
|
19058
|
19059
|
19077
|
19078
|
19127
|
19128
|
19129
|
19135