Bug 10983: Remove unused private subroutines from C4::Budgets
[koha.git] / t / Koha.t
blob3fde068a13b2a6946b41d2fdce03d188b00a47d8
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 use C4::Context;
6 use Test::More tests => 11;
7 use Test::MockModule;
8 use DBD::Mock;
10 use_ok('C4::Koha');
12 my $module_context = new Test::MockModule('C4::Context');
13 $module_context->mock(
14 '_new_dbh',
15 sub {
16 my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
17 || die "Cannot create handle: $DBI::errstr\n";
18 return $dbh;
22 SKIP: {
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');
40 } # End SKIP block
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');
54 my $undef = undef;
55 is(xml_escape($undef), '', 'xml_escape() returns empty string on undef input');
56 my $str = q{'"&<>'};
57 is(xml_escape($str), '&apos;&quot;&amp;&lt;&gt;&apos;', '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');