Bugzilla – Attachment 18382 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.71 KB, created by
Jonathan Druart
on 2013-05-24 12:25:42 UTC
(
hide
)
Description:
Bug 10332: CourseReserves.t needs to create its own data
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-05-24 12:25:42 UTC
Size:
3.71 KB
patch
obsolete
>From 2260506695a52ffb2a695d72f7aa173f98ca8856 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 | 33 ++++++++++++++++++++++----------- > 1 file changed, 22 insertions(+), 11 deletions(-) > >diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t >index 9c3172a..24e5c2b 100755 >--- a/t/db_dependent/CourseReserves.t >+++ b/t/db_dependent/CourseReserves.t >@@ -3,15 +3,18 @@ > # 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; >@@ -23,9 +26,14 @@ 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 +63,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 +78,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 ); >@@ -85,4 +93,7 @@ $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