Lines 3-17
Link Here
|
3 |
# This is to test C4/Members |
3 |
# This is to test C4/Members |
4 |
# It requires a working Koha database with the sample data |
4 |
# It requires a working Koha database with the sample data |
5 |
|
5 |
|
6 |
use strict; |
6 |
use Modern::Perl; |
7 |
use warnings; |
|
|
8 |
|
7 |
|
9 |
use Test::More tests => 16; |
8 |
use Test::More tests => 20; |
10 |
use Data::Dumper; |
9 |
use Data::Dumper; |
11 |
|
10 |
|
12 |
BEGIN { |
11 |
BEGIN { |
|
|
12 |
use_ok('C4::Biblio'); |
13 |
use_ok('C4::Context'); |
13 |
use_ok('C4::Context'); |
14 |
use_ok('C4::CourseReserves', qw/:all/); |
14 |
use_ok('C4::CourseReserves', qw/:all/); |
|
|
15 |
use_ok('C4::Items', qw(AddItemFromMarc)); |
16 |
use_ok('MARC::Field'); |
17 |
use_ok('MARC::Record'); |
15 |
} |
18 |
} |
16 |
|
19 |
|
17 |
my $dbh = C4::Context->dbh; |
20 |
my $dbh = C4::Context->dbh; |
Lines 23-31
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10");
Link Here
|
23 |
$sth->execute(); |
26 |
$sth->execute(); |
24 |
my @borrowers = @{ $sth->fetchall_arrayref( {} ) }; |
27 |
my @borrowers = @{ $sth->fetchall_arrayref( {} ) }; |
25 |
|
28 |
|
26 |
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10"); |
29 |
# Create the item |
27 |
$sth->execute(); |
30 |
my $record = MARC::Record->new(); |
28 |
my @items = @{ $sth->fetchall_arrayref( {} ) }; |
31 |
$record->append_fields( |
|
|
32 |
MARC::Field->new( '952', '0', '0', a => 'CPL', b => 'CPL' ) |
33 |
); |
34 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); |
35 |
my @iteminfo = C4::Items::AddItemFromMarc( $record, $biblionumber ); |
36 |
my $itemnumber = $iteminfo[2]; |
29 |
|
37 |
|
30 |
my $course_id = ModCourse( |
38 |
my $course_id = ModCourse( |
31 |
course_name => "Test Course", |
39 |
course_name => "Test Course", |
Lines 55-65
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrow
Link Here
|
55 |
my $course_instructors = GetCourseInstructors($course_id); |
63 |
my $course_instructors = GetCourseInstructors($course_id); |
56 |
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); |
64 |
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); |
57 |
|
65 |
|
58 |
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} ); |
66 |
my $ci_id = ModCourseItem( 'itemnumber' => $itemnumber ); |
59 |
ok( $ci_id, "ModCourseItem returned valid data" ); |
67 |
ok( $ci_id, "ModCourseItem returned valid data" ); |
60 |
|
68 |
|
61 |
my $course_item = GetCourseItem( 'ci_id' => $ci_id ); |
69 |
my $course_item = GetCourseItem( 'ci_id' => $ci_id ); |
62 |
ok( $course_item->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetCourseItem returns valid data" ); |
70 |
ok( $course_item->{'itemnumber'} eq $itemnumber, "GetCourseItem returns valid data" ); |
63 |
|
71 |
|
64 |
my $cr_id = ModCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id ); |
72 |
my $cr_id = ModCourseReserve( 'course_id' => $course_id, 'ci_id' => $ci_id ); |
65 |
ok( $cr_id, "ModCourseReserve returns valid data" ); |
73 |
ok( $cr_id, "ModCourseReserve returns valid data" ); |
Lines 70-77
ok( $course_reserve->{'cr_id'} eq $cr_id, "GetCourseReserve returns valid data"
Link Here
|
70 |
my $course_reserves = GetCourseReserves( 'course_id' => $course_id ); |
78 |
my $course_reserves = GetCourseReserves( 'course_id' => $course_id ); |
71 |
ok( $course_reserves->[0]->{'ci_id'} eq $ci_id, "GetCourseReserves returns valid data." ); |
79 |
ok( $course_reserves->[0]->{'ci_id'} eq $ci_id, "GetCourseReserves returns valid data." ); |
72 |
|
80 |
|
73 |
my $info = GetItemCourseReservesInfo( itemnumber => $items[0]->{'itemnumber'} ); |
81 |
my $info = GetItemCourseReservesInfo( itemnumber => $itemnumber ); |
74 |
ok( $info->[0]->{'itemnumber'} eq $items[0]->{'itemnumber'}, "GetItemReservesInfo returns valid data." ); |
82 |
ok( $info->[0]->{'itemnumber'} eq $itemnumber, "GetItemReservesInfo returns valid data." ); |
75 |
|
83 |
|
76 |
DelCourseReserve( 'cr_id' => $cr_id ); |
84 |
DelCourseReserve( 'cr_id' => $cr_id ); |
77 |
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); |
85 |
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); |
Lines 85-88
$dbh->do("TRUNCATE TABLE course_instructors");
Link Here
|
85 |
$dbh->do("TRUNCATE TABLE courses"); |
93 |
$dbh->do("TRUNCATE TABLE courses"); |
86 |
$dbh->do("TRUNCATE TABLE course_reserves"); |
94 |
$dbh->do("TRUNCATE TABLE course_reserves"); |
87 |
|
95 |
|
88 |
exit; |
96 |
END { |
|
|
97 |
C4::Items::DelItem( $dbh, $biblionumber, $itemnumber ); |
98 |
C4::Biblio::DelBiblio( $biblionumber ); |
99 |
}; |
89 |
- |
|
|