[Koha-patches] [PATCH] Follow up for bug 5880: Added unit tests for the two new subroutines

Julian Maurice julian.maurice at biblibre.com
Thu Mar 17 12:30:53 CET 2011


---
 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



More information about the Koha-patches mailing list