#!/usr/bin/perl
use Modern::Perl;
+use Koha::Database;
use Koha::DateUtils;
use Koha::Libraries;
use_ok('C4::NewsChannels');
}
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
-# Start transaction
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
-
# Add LIB1, if it doesn't exist.
my $addbra = 'LIB1';
unless ( Koha::Libraries->find($addbra) ) {
content => $new1,
lang => $lang1,
expirationdate => $expirationdate1,
- timestamp => $timestamp1,
+ published_on=> $timestamp1,
number => $number1,
branchcode => 'LIB1',
};
content => $new2,
lang => $lang2,
expirationdate => $expirationdate2,
- timestamp => $timestamp2,
+ published_on=> $timestamp2,
number => $number2,
borrowernumber => $brwrnmbr,
branchcode => 'LIB1',
title => $title3,
content => $new3,
lang => $lang3,
- timestamp => $timestamp3,
+ published_on=> $timestamp3,
number => $number3,
borrowernumber => $brwrnmbr,
branchcode => 'LIB1',
# We need to determine the idnew in a non-MySQLism way.
# This should be good enough.
my $query =
-q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-30'; };
+q{ SELECT idnew from opac_news WHERE published_on='2000-01-01' AND expirationdate='2999-12-30'; };
my ( $idnew1 ) = $dbh->selectrow_array( $query );
$query =
-q{ SELECT idnew from opac_news WHERE timestamp='2000-01-01' AND expirationdate='2999-12-31'; };
+q{ SELECT idnew from opac_news WHERE published_on='2000-01-01' AND expirationdate='2999-12-31'; };
my ( $idnew2 ) = $dbh->selectrow_array( $query );
$query =
-q{ SELECT idnew from opac_news WHERE timestamp='2000-01-02'; };
+q{ SELECT idnew from opac_news WHERE published_on='2000-01-02'; };
my ( $idnew3 ) = $dbh->selectrow_array( $query );
# Test upd_opac_new
$timestamp2 = output_pref( { dt => dt_from_string( $timestamp2 ), dateonly => 1 } );
$expirationdate2 = output_pref( { dt => dt_from_string( $expirationdate2) , dateonly => 1 } );
+my $updated_on = %{get_opac_new($idnew1)}{updated_on};
is_deeply(
get_opac_new($idnew1),
{
content => $new1,
lang => $lang1,
expirationdate => $expirationdate1,
- timestamp => $timestamp1,
+ published_on=> $timestamp1,
number => $number1,
borrowernumber => undef,
idnew => $idnew1,
branchname => "$addbra branch",
branchcode => $addbra,
- # this represents $lang => 1 in the hash
- # that's returned... which seems a little
- # redundant given that there's a perfectly
- # good 'lang' key in the hash
- '' => 1,
+ updated_on => $updated_on,
},
'got back expected news item via get_opac_new - ID 1'
);
# Test get_opac_new (single news item)
+$updated_on = %{get_opac_new($idnew2)}{updated_on};
is_deeply(
get_opac_new($idnew2),
{
content => $new2,
lang => $lang2,
expirationdate => $expirationdate2,
- timestamp => $timestamp2,
+ published_on=> $timestamp2,
number => $number2,
borrowernumber => $brwrnmbr,
idnew => $idnew2,
branchname => "$addbra branch",
branchcode => $addbra,
- '' => 1,
+ updated_on => $updated_on,
},
'got back expected news item via get_opac_new - ID 2'
);
ok($check==3,'Both with and without author data tested');
done_testing();
};
-
-$dbh->rollback;