Bug 10458: Remove obsolete Z3950 module and test
[koha_fer] / t / db_dependent / Koha.t
index e53e936..1a68c7d 100644 (file)
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use C4::Context;
 
-use Test::More tests => 4;
+use Test::More tests => 6;
 use DateTime::Format::MySQL;
 
 eval {use Test::Deep;};
@@ -32,9 +32,7 @@ subtest 'Authorized Values Tests' => sub {
 
 
 # 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);
-    my $insert_success = $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
+    my $insert_success = AddAuthorisedValue($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
     ok($insert_success, "Insert data in database");
 
 
@@ -57,11 +55,32 @@ subtest 'Authorized Values Tests' => sub {
 
 # Clean up
     if($insert_success){
-        $query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;";
-        $sth = $dbh->prepare($query);
+        my $query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;";
+        my $sth = $dbh->prepare($query);
         $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
     }
 };
+
+subtest 'Itemtype info Tests' => sub {
+    like ( getitemtypeinfo('BK')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
+    like ( getitemtypeinfo('BK', 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
+    like ( getitemtypeinfo('BK', 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 ### test for C4::Koha->GetDailyQuote()
 SKIP:
     {
@@ -109,3 +128,36 @@ SKIP:
             }
         };
 }
+
+
+#
+# test that &slashifyDate returns correct (non-US) date
+#
+subtest 'Date and ISBN tests' => sub {
+    plan tests => 7;
+
+    my $date    = "01/01/2002";
+    my $newdate = &slashifyDate("2002-01-01");
+    my $isbn13  = "9780330356473";
+    my $isbn13D = "978-0-330-35647-3";
+    my $isbn10  = "033035647X";
+    my $isbn10D = "0-330-35647-X";
+    ok( $date eq $newdate, 'slashifyDate' );
+    my $undef = undef;
+    is( xml_escape($undef), '',
+        'xml_escape() returns empty string on undef input' );
+    my $str = q{'"&<>'};
+    is(
+        xml_escape($str),
+        '&apos;&quot;&amp;&lt;&gt;&apos;',
+        'xml_escape() works as expected'
+    );
+    is( $str, q{'"&<>'}, '... and does not change input in place' );
+    is( C4::Koha::_isbn_cleanup('0-590-35340-3'),
+        '0590353403', '_isbn_cleanup removes hyphens' );
+    is( C4::Koha::_isbn_cleanup('0590353403 (pbk.)'),
+        '0590353403', '_isbn_cleanup removes parenthetical' );
+    is( C4::Koha::_isbn_cleanup('978-0-321-49694-2'),
+        '0321496949', '_isbn_cleanup converts ISBN-13 to ISBN-10' );
+
+};