Bugzilla – Attachment 26590 Details for
Bug 7567
News by Library: refactor, enhance, and fix
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7567 - Testing for C4/NewsChannel.pm
Bug-7567---Testing-for-C4NewsChannelpm.patch (text/plain), 4.75 KB, created by
Mark Tompsett
on 2014-03-26 15:56:14 UTC
(
hide
)
Description:
Bug 7567 - Testing for C4/NewsChannel.pm
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2014-03-26 15:56:14 UTC
Size:
4.75 KB
patch
obsolete
>From 24cff9623b82716f9fc5cfb45951bbc4b98f093c Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 12 Dec 2013 23:19:18 -0500 >Subject: [PATCH] Bug 7567 - Testing for C4/NewsChannel.pm > >Testing was lacking, this tests every function call. As a >side effect, this moved the stub of a test file from >t/NewsChannels.t to t/db_dependent/NewsChannels.t, since the >table opac_news must exist. > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >Passes all 8 tests >--- > t/NewsChannels.t | 14 ------- > t/db_dependent/NewsChannels.t | 92 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 92 insertions(+), 14 deletions(-) > delete mode 100755 t/NewsChannels.t > create mode 100755 t/db_dependent/NewsChannels.t > >diff --git a/t/NewsChannels.t b/t/NewsChannels.t >deleted file mode 100755 >index bbcaab1..0000000 >--- a/t/NewsChannels.t >+++ /dev/null >@@ -1,14 +0,0 @@ >-#!/usr/bin/perl >-# >-# This Koha test module is a stub! >-# Add more tests here!!! >- >-use strict; >-use warnings; >- >-use Test::More tests => 1; >- >-BEGIN { >- use_ok('C4::NewsChannels'); >-} >- >diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t >new file mode 100755 >index 0000000..261abd5 >--- /dev/null >+++ b/t/db_dependent/NewsChannels.t >@@ -0,0 +1,92 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use C4::Dates qw(format_date); >+use C4::Branch qw(GetBranchName); >+use Test::More tests => 8; >+ >+BEGIN { >+ use_ok('C4::NewsChannels'); >+} >+ >+my $dbh = C4::Context->dbh; >+ >+# Start transaction >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# Test add_opac_new >+my $timestamp = '2000-01-01'; >+my ( $timestamp1, $timestamp2 ) = ( $timestamp, $timestamp ); >+my ($title1, $new1, >+ $lang1, $expirationdate1, $number1) = >+ ( 'News Title', '<p>We have some exciting news!</p>', >+ '', '2999-12-30', 1 ); >+my $rv = add_opac_new( $title1, $new1, $lang1, $expirationdate1, $timestamp1, $number1 ); >+ok($rv==1,"Successfully added the first dummy news item!"); >+ >+my ($title2, $new2, >+ $lang2, $expirationdate2, $number2) = >+ ( 'News Title2', '<p>We have some exciting news!</p>', >+ '', '2999-12-31', 1 ); >+$rv = add_opac_new( $title2, $new2, $lang2, $expirationdate2, $timestamp2, $number2 ); >+ok($rv==1,"Successfully added the second dummy news item!"); >+ >+# We need to determine the idnew in a non-MySQLism way. >+# This should be good enough. >+my $sth = $dbh->prepare(q{ >+ SELECT idnew from opac_news >+ WHERE timestamp='2000-01-01' AND >+ expirationdate='2999-12-30'; >+ }); >+$sth->execute(); >+my $idnew1 = $sth->fetchrow; >+$sth = $dbh->prepare(q{ >+ SELECT idnew from opac_news >+ WHERE timestamp='2000-01-01' AND >+ expirationdate='2999-12-31'; >+ }); >+$sth->execute(); >+my $idnew2 = $sth->fetchrow; >+ >+# Test upd_opac_new >+$new2 = '<p>Update! There is no news!</p>'; >+$rv = upd_opac_new( $idnew2, $title2, $new2, $lang2, $expirationdate2, $timestamp2, $number2 ); >+ok($rv==1,"Successfully updated second dummy news item!"); >+ >+# Test get_opac_new (single news item) >+$timestamp1 = format_date( $timestamp1 ); >+$expirationdate1 = format_date( $expirationdate1 ); >+$timestamp2 = format_date( $timestamp2 ); >+$expirationdate2 = format_date( $expirationdate2 ); >+ >+my $hashref_check = get_opac_new($idnew1); >+my $failure = 0; >+if ($hashref_check->{title} ne $title1) { $failure = 1; } >+if ($hashref_check->{new} ne $new1) { $failure = 1; } >+if ($hashref_check->{lang} ne $lang1) { $failure = 1; } >+if ($hashref_check->{expirationdate} ne $expirationdate1) { $failure = 1; } >+if ($hashref_check->{timestamp} ne $timestamp1) { $failure = 1; } >+if ($hashref_check->{number} ne $number1) { $failure = 1; } >+ok($failure==0,"Successfully tested get_opac_new id1!"); >+ >+# Test get_opac_new (single news item) >+$hashref_check = get_opac_new($idnew2); >+$failure = 0; >+if ($hashref_check->{title} ne $title2) { $failure = 1; } >+if ($hashref_check->{new} ne $new2) { $failure = 1; } >+if ($hashref_check->{lang} ne $lang2) { $failure = 1; } >+if ($hashref_check->{expirationdate} ne $expirationdate2) { $failure = 1; } >+if ($hashref_check->{timestamp} ne $timestamp2) { $failure = 1; } >+if ($hashref_check->{number} ne $number2) { $failure = 1; } >+ok($failure==0,"Successfully tested get_opac_new id2!"); >+ >+# Test get_opac_news (multiple news items) >+my ($opac_news_count, $arrayref_opac_news) = get_opac_news(0,''); >+ok($opac_news_count>=2,"Successfully tested get_opac_news!"); >+ >+# Test GetNewsToDisplay >+($opac_news_count, $arrayref_opac_news) = GetNewsToDisplay(''); >+ok($opac_news_count>=2,"Successfully tested GetNewsToDisplay!"); >+ >+$dbh->rollback; >-- >1.7.9.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 7567
:
22863
|
22917
|
22920
|
23350
|
23351
|
23352
|
23362
|
23368
|
23378
|
23383
|
23386
|
23474
|
23475
|
23501
|
23544
|
23547
|
23552
|
23553
|
23554
|
23559
|
23664
|
23703
|
23704
|
23705
|
25316
|
25317
|
25318
|
25319
|
25320
|
25321
|
25322
|
25323
|
25324
|
25325
|
25331
|
25332
|
25333
|
26510
|
26511
|
26590
|
26591
|
26592
|
26593
|
26594
|
26595
|
26596
|
26597
|
26598
|
26599
|
26600
|
26601
|
26602
|
26603
|
26604
|
26605
|
26606
|
26607
|
26608
|
26609
|
26610
|
26611
|
26612
|
26631
|
26632
|
26633
|
26634
|
26635
|
26636
|
26637
|
26638
|
26639
|
26640
|
26641
|
26642
|
26643
|
26644
|
26647