From ef4c5a48d5b0758699af219befde06e416ed8ab5 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 3 Aug 2020 14:27:24 +0000 Subject: [PATCH] Bug 21066: Update NewsChannels.t Content-Type: text/plain; charset=utf-8 Removing the weird '' => 1 from the hash too. NOTE: The following line in the module seems to be useless: $data->{$data->{'lang'}} = 1 if defined $data->{lang}; Test plan: Run t/db_dependent/NewsChannels.t Run t/db_dependent/Koha/News.t Signed-off-by: Marcel de Rooy --- C4/NewsChannels.pm | 1 - t/db_dependent/NewsChannels.t | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index f39113cd89..e9733901a5 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -135,7 +135,6 @@ sub get_opac_new { my $sth = $dbh->prepare($query); $sth->execute($idnew); my $data = $sth->fetchrow_hashref; - $data->{$data->{'lang'}} = 1 if defined $data->{lang}; $data->{expirationdate} = output_pref({ dt => dt_from_string( $data->{expirationdate} ), dateonly => 1 }) if ( $data->{expirationdate} ); $data->{publicationdate} = output_pref({ dt => dt_from_string( $data->{publicationdate} ), dateonly => 1 }); return $data; diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t index 928ddd5cd5..f6cf6bcee0 100644 --- a/t/db_dependent/NewsChannels.t +++ b/t/db_dependent/NewsChannels.t @@ -74,7 +74,7 @@ my $href_entry1 = { content => $new1, lang => $lang1, expirationdate => $expirationdate1, - timestamp => $timestamp1, + publicationdate=> $timestamp1, number => $number1, branchcode => 'LIB1', }; @@ -89,7 +89,7 @@ my $href_entry2 = { content => $new2, lang => $lang2, expirationdate => $expirationdate2, - timestamp => $timestamp2, + publicationdate=> $timestamp2, number => $number2, borrowernumber => $brwrnmbr, branchcode => 'LIB1', @@ -103,7 +103,7 @@ my $href_entry3 = { title => $title3, content => $new3, lang => $lang3, - timestamp => $timestamp3, + publicationdate=> $timestamp3, number => $number3, borrowernumber => $brwrnmbr, branchcode => 'LIB1', @@ -114,14 +114,14 @@ is( $rv, 1, 'Successfully added the third dummy news item without expiration dat # 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 publicationdate='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 publicationdate='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 publicationdate='2000-01-02'; }; my ( $idnew3 ) = $dbh->selectrow_array( $query ); # Test upd_opac_new @@ -140,6 +140,7 @@ $expirationdate1 = output_pref( { dt => dt_from_string( $expirationdate1 ), date $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), { @@ -147,22 +148,19 @@ is_deeply( content => $new1, lang => $lang1, expirationdate => $expirationdate1, - timestamp => $timestamp1, + publicationdate=> $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), { @@ -170,13 +168,13 @@ is_deeply( content => $new2, lang => $lang2, expirationdate => $expirationdate2, - timestamp => $timestamp2, + publicationdate=> $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' ); -- 2.11.0