From 5bad52eef23d8f474101efdde76096da12b65b10 Mon Sep 17 00:00:00 2001 From: Mason James Date: Fri, 6 Jul 2012 16:19:51 +1200 Subject: [PATCH] added date and ISBN tests to Koha.t modified: Koha.t $ prove -v ./Koha.t 1..5 ok 1 - use C4::Koha; ok 2 - use C4::Members; 1..6 ok 1 - Insert data in database ok 2 - GetAuthorisedValueByCode ok 3 - GetKohaImageurlFromAuthorisedValues ok 4 - lost and paid works ok 5 - Child area works ok 6 - Withdrawn works ok 3 - Authorized Values Tests 1..4 ok 1 - C4::Koha->can('GetDailyQuote') ok 2 - Got a quote based on id. ok 3 - Got a random quote. ok 4 - Got a quote based on today's date. ok 4 - Daily Quotes Test 1..7 ok 1 - slashifyDate ok 2 - xml_escape() returns empty string on undef input ok 3 - xml_escape() works as expected ok 4 - ... and does not change input in place ok 5 - _isbn_cleanup removes hyphens ok 6 - _isbn_cleanup removes parenthetical ok 7 - _isbn_cleanup converts ISBN-13 to ISBN-10 ok 5 - Date and ISBN tests ok All tests successful. Files=1, Tests=5, 1 wallclock secs ( 0.02 usr 0.01 sys + 0.48 cusr 0.06 csys = 0.57 CPU) Result: PASS http://bugs.koha-community.org/show_bug.cgi?id=5327 --- t/db_dependent/Koha.t | 50 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index e53e93659e..6ade4a76ab 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -7,7 +7,7 @@ use strict; use warnings; use C4::Context; -use Test::More tests => 4; +use Test::More tests => 5; use DateTime::Format::MySQL; eval {use Test::Deep;}; @@ -62,6 +62,21 @@ subtest 'Authorized Values Tests' => sub { $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); } }; + + + + + + + + + + + + + + + ### test for C4::Koha->GetDailyQuote() SKIP: { @@ -109,3 +124,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), + ''"&<>'', + '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' ); + +}; -- 2.39.5