View | Details | Raw Unified | Return to bug 16550
Collapse All | Expand All

(-)a/t/db_dependent/NewsChannels.t (-18 / +10 lines)
Lines 29-35 my $addcat = 'CAT1'; Link Here
29
    my $sth = $dbh->prepare( q{ SELECT categorycode FROM categories WHERE categorycode = ? } );
29
    my $sth = $dbh->prepare( q{ SELECT categorycode FROM categories WHERE categorycode = ? } );
30
    $sth->execute ( $addcat );
30
    $sth->execute ( $addcat );
31
    if ( not defined $sth->fetchrow () ) {
31
    if ( not defined $sth->fetchrow () ) {
32
        diag("Category $addcat not found, inserting");
33
        $dbh->do( q{ INSERT INTO categories (categorycode,description) VALUES (?,?) },
32
        $dbh->do( q{ INSERT INTO categories (categorycode,description) VALUES (?,?) },
34
            undef, ( $addcat, "$addcat description") );
33
            undef, ( $addcat, "$addcat description") );
35
    }
34
    }
Lines 47-53 my $brwrnmbr; Link Here
47
46
48
    # Not found, let us insert it.
47
    # Not found, let us insert it.
49
    if ( not defined $brwrnmbr ) {
48
    if ( not defined $brwrnmbr ) {
50
        diag("Borrower $addbrwr not found, inserting");
51
        $dbh->do( q{ INSERT INTO borrowers (surname, address, city, branchcode, categorycode) VALUES (?, ?, ?, ?, ?) },
49
        $dbh->do( q{ INSERT INTO borrowers (surname, address, city, branchcode, categorycode) VALUES (?, ?, ?, ?, ?) },
52
            undef, ($addbrwr, '(test) address', '(test) city', $addbra, $addcat) );
50
            undef, ($addbrwr, '(test) address', '(test) city', $addbra, $addcat) );
53
51
Lines 65-71 ok ( defined $brwrnmbr ); Link Here
65
63
66
# Test add_opac_new
64
# Test add_opac_new
67
my $rv = add_opac_new();    # intentionally bad
65
my $rv = add_opac_new();    # intentionally bad
68
ok( $rv == 0, 'Correctly failed on no parameter!' );
66
is( $rv, 0, 'Correctly failed on no parameter!' );
69
67
70
my $timestamp = '2000-01-01';
68
my $timestamp = '2000-01-01';
71
my ( $timestamp1, $timestamp2 ) = ( $timestamp, $timestamp );
69
my ( $timestamp1, $timestamp2 ) = ( $timestamp, $timestamp );
Lines 83-89 my $href_entry1 = { Link Here
83
};
81
};
84
82
85
$rv = add_opac_new($href_entry1);
83
$rv = add_opac_new($href_entry1);
86
ok( $rv == 1, 'Successfully added the first dummy news item!' );
84
is( $rv, 1, 'Successfully added the first dummy news item!' );
87
85
88
my ( $title2, $new2, $lang2, $expirationdate2, $number2 ) =
86
my ( $title2, $new2, $lang2, $expirationdate2, $number2 ) =
89
  ( 'News Title2', '<p>We have some exciting news!</p>', q{}, '2999-12-31', 1 );
87
  ( 'News Title2', '<p>We have some exciting news!</p>', q{}, '2999-12-31', 1 );
Lines 98-104 my $href_entry2 = { Link Here
98
    branchcode     => 'LIB1',
96
    branchcode     => 'LIB1',
99
};
97
};
100
$rv = add_opac_new($href_entry2);
98
$rv = add_opac_new($href_entry2);
101
ok( $rv == 1, 'Successfully added the second dummy news item!' );
99
is( $rv, 1, 'Successfully added the second dummy news item!' );
102
100
103
my ( $title3, $new3, $lang3, $number3 ) =
101
my ( $title3, $new3, $lang3, $number3 ) =
104
  ( 'News Title3', '<p>News without expiration date</p>', q{}, 1 );
102
  ( 'News Title3', '<p>News without expiration date</p>', q{}, 1 );
Lines 112-147 my $href_entry3 = { Link Here
112
    branchcode     => 'LIB1',
110
    branchcode     => 'LIB1',
113
};
111
};
114
$rv = add_opac_new($href_entry3);
112
$rv = add_opac_new($href_entry3);
115
ok( $rv == 1, 'Successfully added the third dummy news item without expiration date!' );
113
is( $rv, 1, 'Successfully added the third dummy news item without expiration date!' );
116
114
117
# We need to determine the idnew in a non-MySQLism way.
115
# We need to determine the idnew in a non-MySQLism way.
118
# This should be good enough.
116
# This should be good enough.
119
my $query =
117
my $query =
120
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-30'; };
118
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-30'; };
121
my $sth = $dbh->prepare($query);
119
my ( $idnew1 ) = $dbh->selectrow_array( $query );
122
$sth->execute();
123
my $idnew1 = $sth->fetchrow;
124
$query =
120
$query =
125
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-31'; };
121
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-31'; };
126
$sth = $dbh->prepare($query);
122
my ( $idnew2 ) = $dbh->selectrow_array( $query );
127
$sth->execute();
128
my $idnew2 = $sth->fetchrow;
129
123
130
$query =
124
$query =
131
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-02'; };
125
q{ SELECT idnew from opac_news WHERE timestamp='2000-01-02'; };
132
$sth = $dbh->prepare($query);
126
my ( $idnew3 ) = $dbh->selectrow_array( $query );
133
$sth->execute();
134
my $idnew3 = $sth->fetchrow;
135
127
136
# Test upd_opac_new
128
# Test upd_opac_new
137
$rv = upd_opac_new();    # intentionally bad parmeters
129
$rv = upd_opac_new();    # intentionally bad parmeters
138
ok( $rv == 0, 'Correctly failed on no parameter!' );
130
is( $rv, 0, 'Correctly failed on no parameter!' );
139
131
140
$new2                 = '<p>Update! There is no news!</p>';
132
$new2                 = '<p>Update! There is no news!</p>';
141
$href_entry2->{new}   = $new2;
133
$href_entry2->{new}   = $new2;
142
$href_entry2->{idnew} = $idnew2;
134
$href_entry2->{idnew} = $idnew2;
143
$rv                   = upd_opac_new($href_entry2);
135
$rv                   = upd_opac_new($href_entry2);
144
ok( $rv == 1, 'Successfully updated second dummy news item!' );
136
is( $rv, 1, 'Successfully updated second dummy news item!' );
145
137
146
# Test get_opac_new (single news item)
138
# Test get_opac_new (single news item)
147
$timestamp1      = output_pref( { dt => dt_from_string( $timestamp1 ), dateonly => 1 } );
139
$timestamp1      = output_pref( { dt => dt_from_string( $timestamp1 ), dateonly => 1 } );
Lines 192-198 is_deeply( Link Here
192
184
193
# Test get_opac_new (single news item without expiration date)
185
# Test get_opac_new (single news item without expiration date)
194
my $news3 = get_opac_new($idnew3);
186
my $news3 = get_opac_new($idnew3);
195
ok (! $news3->{ expirationdate }, "Expiration date should be empty");
187
is($news3->{ expirationdate }, undef, "Expiration date should be empty");
196
188
197
# Test get_opac_news (multiple news items)
189
# Test get_opac_news (multiple news items)
198
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' );
190
my ( $opac_news_count, $arrayref_opac_news ) = get_opac_news( 0, q{}, 'LIB1' );
(-)a/tools/koha-news.pl (-2 / +1 lines)
Lines 41-47 my $id = $cgi->param('id'); Link Here
41
my $title          = $cgi->param('title');
41
my $title          = $cgi->param('title');
42
my $new            = $cgi->param('new');
42
my $new            = $cgi->param('new');
43
my $expirationdate;
43
my $expirationdate;
44
if ( scalar $cgi->param('expirationdate') ) {
44
if ( $cgi->param('expirationdate') ) {
45
    $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
45
    $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 });
46
}
46
}
47
my $timestamp      = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 });
47
my $timestamp      = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 });
48
- 

Return to bug 16550