Bugzilla – Attachment 10659 Details for
Bug 5327
Omnibus for unit tests required for all C4 modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5327 - Unit tests required for all C4 modules
Bug-5327---Unit-tests-required-for-all-C4-modules.patch (text/plain), 7.07 KB, created by
Mason James
on 2012-07-06 03:46:34 UTC
(
hide
)
Description:
Bug 5327 - Unit tests required for all C4 modules
Filename:
MIME Type:
Creator:
Mason James
Created:
2012-07-06 03:46:34 UTC
Size:
7.07 KB
patch
obsolete
>From 296e364e26792b5218f90e25afa8fe2ce2ebdf49 Mon Sep 17 00:00:00 2001 >From: Mason James <mtj@kohaaloha.com> >Date: Fri, 6 Jul 2012 15:43:06 +1200 >Subject: [PATCH] Bug 5327 - Unit tests required for all C4 modules >Content-Type: text/plain; charset="utf-8" >http://koha-community.org > > renamed: Koha.t -> db_dependent/Koha.t > >Signed-off-by: Mason James <mtj@kohaaloha.com> >--- > t/Koha.t | 31 ------------- > t/db_dependent/Koha.t | 120 ++++++++---------------------------------------- > 2 files changed, 20 insertions(+), 131 deletions(-) > delete mode 100755 t/Koha.t > mode change 100644 => 100755 t/db_dependent/Koha.t > >diff --git a/t/Koha.t b/t/Koha.t >deleted file mode 100755 >index 025ab98..0000000 >--- a/t/Koha.t >+++ /dev/null >@@ -1,31 +0,0 @@ >-#!/usr/bin/perl >-use strict; >-use warnings; >- >-use Test::More tests => 8; >- >-use_ok('C4::Koha'); >- >-# >-# test that &slashifyDate returns correct (non-US) date >-# >-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'); >- >- >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >old mode 100644 >new mode 100755 >index e53e936..025ab98 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -1,111 +1,31 @@ > #!/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 => 4; >-use DateTime::Format::MySQL; >- >-eval {use Test::Deep;}; >- >-BEGIN { >- use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote )); >- use_ok('C4::Members'); >-} >- >-my $dbh = C4::Context->dbh; >- >-subtest 'Authorized Values Tests' => sub { >- plan tests => 6; >- >- my $data = { >- category => 'CATEGORY', >- authorised_value => 'AUTHORISED_VALUE', >- lib => 'LIB', >- lib_opac => 'LIBOPAC', >- imageurl => 'IMAGEURL' >- }; >- >- >-# 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}); >- ok($insert_success, "Insert data in database"); >- >- >-# Tests >- SKIP: { >- skip "INSERT failed", 5 unless $insert_success; > >- is ( GetAuthorisedValueByCode($data->{category}, $data->{authorised_value}), $data->{lib}, "GetAuthorisedValueByCode" ); >- is ( GetKohaImageurlFromAuthorisedValues($data->{category}, $data->{lib}), $data->{imageurl}, "GetKohaImageurlFromAuthorisedValues" ); >+use Test::More tests => 8; > >- my $sortdet=C4::Members::GetSortDetails("lost", "3"); >- is ($sortdet, "Lost and Paid For", "lost and paid works"); >+use_ok('C4::Koha'); > >- my $sortdet2=C4::Members::GetSortDetails("loc", "child"); >- is ($sortdet2, "Children's Area", "Child area works"); >- >- my $sortdet3=C4::Members::GetSortDetails("withdrawn", "1"); >- is ($sortdet3, "Withdrawn", "Withdrawn works"); >- } >- >-# 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); >- $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >- } >-}; >-### test for C4::Koha->GetDailyQuote() >-SKIP: >- { >- skip "Test::Deep required to run the GetDailyQuote tests.", 1 if $@; >- >- subtest 'Daily Quotes Test' => sub { >- plan tests => 4; >- >- SKIP: { >- >- skip "C4::Koha can't \'GetDailyQuote\'!", 3 unless can_ok('C4::Koha','GetDailyQuote'); >- >- my $expected_quote = { >- id => 3, >- source => 'Abraham Lincoln', >- text => 'Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.', >- timestamp => re('\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}'), #'0000-00-00 00:00:00', >- }; >- >-# test quote retrieval based on id >- >- my $quote = GetDailyQuote('id'=>3); >- cmp_deeply ($quote, $expected_quote, "Got a quote based on id.") or >- diag('Be sure to run this test on a clean install of sample data.'); >- >-# test random quote retrieval >- >- $quote = GetDailyQuote('random'=>1); >- ok ($quote, "Got a random quote."); >+# >+# test that &slashifyDate returns correct (non-US) date >+# >+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"; > >-# test quote retrieval based on today's date >+ok($date eq $newdate, 'slashifyDate'); > >- my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; >- my $sth = C4::Context->dbh->prepare($query); >- $sth->execute(DateTime::Format::MySQL->format_datetime(DateTime->now), $expected_quote->{'id'}); >+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'); > >- DateTime::Format::MySQL->format_datetime(DateTime->now) =~ m/(\d{4}-\d{2}-\d{2})/; >- $expected_quote->{'timestamp'} = re("^$1"); >+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'); > >-# $expected_quote->{'timestamp'} = DateTime::Format::MySQL->format_datetime(DateTime->now); # update the timestamp of expected quote data > >- $quote = GetDailyQuote(); # this is the "default" mode of selection >- cmp_deeply ($quote, $expected_quote, "Got a quote based on today's date.") or >- diag('Be sure to run this test on a clean install of sample data.'); >- } >- }; >-} >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5327
:
2716
|
2726
|
5485
|
6236
|
6237
|
6373
|
6560
|
6561
|
6562
|
6563
|
6613
|
6614
|
6616
|
6620
|
6621
|
6622
|
6643
|
6650
|
6655
|
6679
|
6681
|
6682
|
6683
|
6726
|
6727
|
6728
|
6729
|
6730
|
6731
|
6732
|
6795
|
6799
|
6805
|
6819
|
6826
|
6827
|
6828
|
6834
|
7179
|
7180
|
7181
|
7182
|
7183
|
7184
|
7185
|
7186
|
7187
|
7188
|
7189
|
7190
|
7191
|
7192
|
7194
|
7195
|
7203
|
7206
|
7208
|
7209
|
7220
|
7221
|
7222
|
7223
|
7224
|
7225
|
7226
|
7227
|
7228
|
7229
|
7230
|
7231
|
7232
|
7233
|
7234
|
7235
|
7236
|
7237
|
7238
|
7239
|
7240
|
7241
|
7242
|
7400
|
7402
|
7403
|
7405
|
7573
|
7592
|
7593
|
7594
|
9897
|
10234
|
10616
|
10656
|
10659
|
10660
|
10661
|
10680
|
11141
|
11186
|
11212
|
11213
|
11278
|
11279
|
11280
|
11281
|
11339
|
11340
|
11341
|
11440
|
11467
|
11469
|
11470
|
11471
|
11472
|
11473
|
11500
|
11503
|
11505
|
11506
|
11633
|
11762
|
11763
|
11764
|
11765
|
11846
|
11985
|
11993
|
12002
|
12003