6 use Test::More tests => 11;
12 my $module_context = new Test::MockModule('C4::Context');
13 $module_context->mock(
16 my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
17 || die "Cannot create handle: $DBI::errstr\n";
24 skip "DBD::Mock is too old", 3
25 unless $DBD::Mock::VERSION >= 1.45;
27 my @loc_results = (['category'],['LOC']);
28 my @empty_results = ([]);
29 my @relterms_results = (['category'],['RELTERMS']);
31 my $dbh = C4::Context->dbh();
33 $dbh->{mock_add_resultset} = \@loc_results;
34 is ( IsAuthorisedValueCategory('LOC'), 1, 'LOC is a valid authorized value category');
35 $dbh->{mock_add_resultset} = \@empty_results;
36 is ( IsAuthorisedValueCategory('something'), 0, 'something is not a valid authorized value category');
37 $dbh->{mock_add_resultset} = \@relterms_results;
38 is ( IsAuthorisedValueCategory('RELTERMS'), 1, 'RELTERMS is a valid authorized value category');
43 # test that &slashifyDate returns correct (non-US) date
45 my $date = "01/01/2002";
46 my $newdate = &slashifyDate("2002-01-01");
47 my $isbn13 = "9780330356473";
48 my $isbn13D = "978-0-330-35647-3";
49 my $isbn10 = "033035647X";
50 my $isbn10D = "0-330-35647-X";
52 ok($date eq $newdate, 'slashifyDate');
55 is(xml_escape($undef), '', 'xml_escape() returns empty string on undef input');
57 is(xml_escape($str), ''"&<>'', 'xml_escape() works as expected');
58 is($str, q{'"&<>'}, '... and does not change input in place');
60 is(C4::Koha::_isbn_cleanup('0-590-35340-3'), '0590353403', '_isbn_cleanup removes hyphens');
61 is(C4::Koha::_isbn_cleanup('0590353403 (pbk.)'), '0590353403', '_isbn_cleanup removes parenthetical');
62 is(C4::Koha::_isbn_cleanup('978-0-321-49694-2'), '0321496949', '_isbn_cleanup converts ISBN-13 to ISBN-10');