From fb3c4bbe64298b122171b336c24a33547ad72690 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 27 Oct 2021 12:07:02 +0100 Subject: [PATCH] Bug 29332: Unit tests This patch adds unit tests to ensure we do not leak branch specific addtional contents blocks outside of logged in sessions (i.e. where a users branch is not yet set). --- t/db_dependent/Koha/AdditionalContents.t | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Koha/AdditionalContents.t b/t/db_dependent/Koha/AdditionalContents.t index ac9f998cb1..bf515b1af1 100755 --- a/t/db_dependent/Koha/AdditionalContents.t +++ b/t/db_dependent/Koha/AdditionalContents.t @@ -157,7 +157,7 @@ subtest '->author' => sub { subtest '->search_for_display' => sub { - plan tests => 3; + plan tests => 4; $schema->storage->txn_begin; @@ -243,13 +243,17 @@ subtest '->search_for_display' => sub { }); my $news = Koha::AdditionalContents->search_for_display({ location => 'staff_only' }); - is($news->count, 3, "There are 3 news for staff"); + is($news->count, 1, "There is 1 news for all staff"); + + $news = Koha::AdditionalContents->search_for_display( + { location => 'staff_only', library_id => $library1->branchcode } ); + is( $news->count, 2, "There are 2 news for staff at library1" ); $news = Koha::AdditionalContents->search_for_display({ location => 'opac_only' }); - is($news->count, 0, "There are 0 news for OPAC"); + is($news->count, 0, "There are 0 news for OPAC only"); $news = Koha::AdditionalContents->search_for_display({ location => 'staff_and_opac' }); - is($news->count, 1, "There is 1 news for staff and OPAC"); + is($news->count, 1, "There is 1 news for all staff and all OPAC "); # TODO We should add more tests here -- 2.20.1