From af96835ea6d81af8b68cc855503232fe84fb3f8e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Jun 2013 11:16:10 +0200 Subject: [PATCH] Bug 10332: Data could exist in the courses table. --- C4/CourseReserves.pm | 1 + t/db_dependent/CourseReserves.t | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index c3e25e6..69724d1 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -77,6 +77,7 @@ This module deals with course reserves. sub GetCourse { my ($course_id) = @_; warn whoami() . "( $course_id )" if $DEBUG; + return unless $course_id; my $query = "SELECT * FROM courses WHERE course_id = ?"; my $dbh = C4::Context->dbh; diff --git a/t/db_dependent/CourseReserves.t b/t/db_dependent/CourseReserves.t index a7955e4..e27712a 100755 --- a/t/db_dependent/CourseReserves.t +++ b/t/db_dependent/CourseReserves.t @@ -5,8 +5,7 @@ use Modern::Perl; -use Test::More tests => 20; -use Data::Dumper; +use Test::More tests => 21; BEGIN { use_ok('C4::Biblio'); @@ -46,12 +45,13 @@ $course_id = ModCourse( ); my $course = GetCourse($course_id); - ok( $course->{'course_name'} eq "Test Course", "GetCourse returned correct course" ); ok( $course->{'staff_note'} eq "Test staff note 2", "ModCourse updated course succesfully" ); my $courses = GetCourses(); -ok( $courses->[0]->{'course_name'} eq "Test Course", "GetCourses returns valid array of course data" ); +is( ref($courses), 'ARRAY', "GetCourses returns an array" ); +my @match = map {$_->{course_name} eq 'Test Course'} @$courses; +ok( scalar(@match) > 0, "GetCourses returns valid array of course data" ); ModCourseInstructors( mode => 'add', course_id => $course_id, borrowernumbers => [ $borrowers[0]->{'borrowernumber'} ] ); $course = GetCourse($course_id); -- 1.7.10.4