From 8ae698a9583716fef10d318b871ccbf8e352c993 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 17 Mar 2011 12:26:20 +0100 Subject: [PATCH] Follow up for bug 5880: Added unit tests for the two new subroutines --- t/db_dependent/Koha.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) create mode 100644 t/db_dependent/Koha.t diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t new file mode 100644 index 0000000..bdbb348 --- /dev/null +++ b/t/db_dependent/Koha.t @@ -0,0 +1,39 @@ +#!/usr/bin/perl +# +# This is to test C4/Koha +# It requires a working Koha database with the sample data + +use strict; +use warnings; +use C4::Context; + +use Test::More tests => 3; + +BEGIN { + use_ok('C4::Koha'); +} + +my $data = { + category => 'CATEGORY', + authorised_value => 'AUTHORISED_VALUE', + lib => 'LIB', + lib_opac => 'LIBOPAC', + imageurl => 'IMAGEURL' +}; + +my $dbh = C4::Context->dbh; + +# Insert an entry into authorised_value table +my $query = "INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) VALUES (?,?,?,?,?);"; +my $sth = $dbh->prepare($query); +$sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); + +# Tests +is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); +is ( GetKohaImageurlFromAuthorisedValues($data->{category}, $data->{lib}), $data->{imageurl}, "GetKohaImageurlFromAuthorisedValues" ); + +# Clean up +$query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;"; +$sth = $dbh->prepare($query); +$sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); + -- 1.7.4.1