Lines 10-17
use Test::More tests => 16;
Link Here
|
10 |
use Data::Dumper; |
10 |
use Data::Dumper; |
11 |
|
11 |
|
12 |
BEGIN { |
12 |
BEGIN { |
13 |
use_ok('C4::Context'); |
13 |
use_ok('C4::Context'); |
14 |
use_ok('C4::CourseReserves'); |
14 |
use_ok('C4::CourseReserves'); |
15 |
} |
15 |
} |
16 |
|
16 |
|
17 |
my $dbh = C4::Context->dbh; |
17 |
my $dbh = C4::Context->dbh; |
Lines 21-58
$dbh->do("TRUNCATE TABLE course_reserves");
Link Here
|
21 |
|
21 |
|
22 |
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10"); |
22 |
my $sth = $dbh->prepare("SELECT * FROM borrowers ORDER BY RAND() LIMIT 10"); |
23 |
$sth->execute(); |
23 |
$sth->execute(); |
24 |
my @borrowers = @{$sth->fetchall_arrayref({})}; |
24 |
my @borrowers = @{ $sth->fetchall_arrayref( {} ) }; |
25 |
|
25 |
|
26 |
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10"); |
26 |
$sth = $dbh->prepare("SELECT * FROM items ORDER BY RAND() LIMIT 10"); |
27 |
$sth->execute(); |
27 |
$sth->execute(); |
28 |
my @items = @{$sth->fetchall_arrayref({})}; |
28 |
my @items = @{ $sth->fetchall_arrayref( {} ) }; |
29 |
|
29 |
|
30 |
my $course_id = ModCourse( |
30 |
my $course_id = ModCourse( |
31 |
course_name => "Test Course", |
31 |
course_name => "Test Course", |
32 |
staff_note => "Test staff note", |
32 |
staff_note => "Test staff note", |
33 |
public_note => "Test public note", |
33 |
public_note => "Test public note", |
34 |
); |
34 |
); |
35 |
|
35 |
|
36 |
ok( $course_id, "ModCourse created course successfully" ); |
36 |
ok( $course_id, "ModCourse created course successfully" ); |
37 |
|
37 |
|
38 |
$course_id = ModCourse( |
38 |
$course_id = ModCourse( |
39 |
course_id => $course_id, |
39 |
course_id => $course_id, |
40 |
staff_note => "Test staff note 2", |
40 |
staff_note => "Test staff note 2", |
41 |
); |
41 |
); |
42 |
|
42 |
|
43 |
my $course = GetCourse( $course_id ); |
43 |
my $course = GetCourse($course_id); |
44 |
|
44 |
|
45 |
ok( $course->{'course_name'} eq "Test Course", "GetCourse returned correct course" ); |
45 |
ok( $course->{'course_name'} eq "Test Course", "GetCourse returned correct course" ); |
46 |
ok( $course->{'staff_note'} eq "Test staff note 2", "ModCourse updated course succesfully" ); |
46 |
ok( $course->{'staff_note'} eq "Test staff note 2", "ModCourse updated course succesfully" ); |
47 |
|
47 |
|
48 |
my $courses = GetCourses(); |
48 |
my $courses = GetCourses(); |
49 |
ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" ); |
49 |
ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" ); |
50 |
|
50 |
|
51 |
ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] ); |
51 |
ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] ); |
52 |
$course = GetCourse( $course_id ); |
52 |
$course = GetCourse($course_id); |
53 |
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly"); |
53 |
ok( $course->{'instructors'}->[0]->{'borrowernumber'} == $borrowers[0]->{'borrowernumber'}, "ModCourseInstructors added instructors correctly" ); |
54 |
|
54 |
|
55 |
my $course_instructors = GetCourseInstructors( $course_id ); |
55 |
my $course_instructors = GetCourseInstructors($course_id); |
56 |
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); |
56 |
ok( $course_instructors->[0]->{'borrowernumber'} eq $borrowers[0]->{'borrowernumber'}, "GetCourseInstructors returns valid data" ); |
57 |
|
57 |
|
58 |
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} ); |
58 |
my $ci_id = ModCourseItem( 'itemnumber' => $items[0]->{'itemnumber'} ); |
Lines 77-84
DelCourseReserve( 'cr_id' => $cr_id );
Link Here
|
77 |
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); |
77 |
$course_reserve = GetCourseReserve( 'cr_id' => $cr_id ); |
78 |
ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" ); |
78 |
ok( !defined( $course_reserve->{'cr_id'} ), "DelCourseReserve functions correctly" ); |
79 |
|
79 |
|
80 |
DelCourse( $course_id ); |
80 |
DelCourse($course_id); |
81 |
$course = GetCourse( $course_id ); |
81 |
$course = GetCourse($course_id); |
82 |
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" ); |
82 |
ok( !defined( $course->{'course_id'} ), "DelCourse deleted course successfully" ); |
83 |
|
83 |
|
84 |
$dbh->do("TRUNCATE TABLE course_instructors"); |
84 |
$dbh->do("TRUNCATE TABLE course_instructors"); |
85 |
- |
|
|